From patchwork Tue Mar 8 16:21:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1603077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=T5RNWP9P; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::63d; helo=mail-ej1-x63d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbaeft2iqmgqey5dgtqi@googlegroups.com; receiver=) Received: from mail-ej1-x63d.google.com (mail-ej1-x63d.google.com [IPv6:2a00:1450:4864:20::63d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCgYy0C5Fz9sG9 for ; Wed, 9 Mar 2022 03:21:25 +1100 (AEDT) Received: by mail-ej1-x63d.google.com with SMTP id q22-20020a1709064cd600b006db14922f93sf3029454ejt.7 for ; Tue, 08 Mar 2022 08:21:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646756481; cv=pass; d=google.com; s=arc-20160816; b=Jy0P/DGAQcv1AfVjOdE426fmjcu4X5Sa5yz4xtIw2nsCZH9xJ2IGKTDuWBj7KBL+M6 RdqdvbNvbWKrkPccgCGNlBF0NEVUdtwK+LfYYyhYQkshjZczDpEQZeZ6iZf4AHzqLt5S O8fQ4HfG30mUrD/invHlbogifXWVUBJvOPd5Q3ZXVlKxedFkV5KGwVJi++r8/IUkNUJ3 9fujGYnx7oP5O7S8aqEI43X/rlhb5EaXX/8PfP0bnRDhFjHhzREUCLuZnVQv65Qko+W9 OZ4eIMEF5hzaPgR6Cl+YXkEmfvzQYYwYyHU8Yu38qh3BuvWXOBvLrZt28aJkEIzeoB9d LAjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=lfYVnZxQj7CElX/8lQgqCwCz8JM9xj3oh5CjpCYYCUQ=; b=LWt9i55pykAURtubso6PA7HVPTMnUfSJhHWNg7vHtLcCfA9V/F+wbN9nKbHGE1QP0y GHUddAq2+PoWVhuLCJSQK6IjojbqP15K8sggzYT4M64ztAf5FqujX5RcSp8I7PnHHcI+ jhPXEL9AXYUFEoOYFCMcundkY/GIE8hIOboQ9KLcOdf7x23/cogbvhzKI9Ewk3ZPVwXr SdlhDp2SvCGzVeV2qsglRuwsF8al3iOu4eJexlL9i9DqMTRq/tgsIM4sBb5rfkDAHPhU LAmL1tajV+sXEG6i82Vjz1kS7fCIZ5sjE4fcJLnDav21QeSxzFkD09kO2llRSqSYLn7N wwpw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=lfYVnZxQj7CElX/8lQgqCwCz8JM9xj3oh5CjpCYYCUQ=; b=T5RNWP9PvemnQgROmiWYU4PoTNIYQzyw/WVdgX3VpcP2i72ugspdYC+l7H35+1rcs5 +j3CGTF4JHmLXadFsKpgS5hfqODEsQqNsGyoQMOdtcTdSHDlRkxeMhwn+3f1UkulzyLW gHgZ5jkCdVtyIeuca2CvjQ6B6EymegBHA2DbYn8tnJcffz9/AGInN41Yb9ofqHxtEIV7 vWwnWpXqdNeHSHYy7PI0cuy5KFyPxP3lOMawhsRa86VXJFkJaAZuUPftXRWMKgfLedPd FzSbvM9fvWS6lxzs+Zzy0X3YqVuFHk3MHAAUhqCOQF1LNSxYx5eHREbJctzc5UTjcvyO R5Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=lfYVnZxQj7CElX/8lQgqCwCz8JM9xj3oh5CjpCYYCUQ=; b=5i2MYEPr1zw4fsAf0VucHfGxam5khSdpNNBDMnu/KzXMZPVEGzxOjkMoksen5XFX80 MaVehgS05aqLLn08xLDfPwHnvz76LVkRyv7EhEQk9tDfqMsR2kZwFmBuseOsUtATLH68 rEfx8Ns4dWWTDkHjktpqR3zisSUKI5UgqSQQOlbtcEzLDVRX0BP017VYKtRNkWAeaaKR cN/cgp+DdxZ5c4h80p5bVIzpUYUabFpAp8XSMlZsb7ihi5PPpcTSC1Ge7evnB0M5mUaU nQBjZl9W8u5PuB6X2y2Ey4kNxXh+VBxSiqvxdFOOnfIXl+Z8w0DRA/JpphFqZIPLBgpg tgUg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531d4BAQC0XZXvCIpn+Dk23opK2VMeslQr6oa1RKAZkEgu9zw7R3 Xf4ACm3AKGUOZsjJ2rKU3Tc= X-Google-Smtp-Source: ABdhPJydsFHMou9tXLzl9n5lx+ezFOiZe/6mzUgd5o+ey7PQzvbPLdFZM1ztMk8bzM1RWIoxdQ3iWA== X-Received: by 2002:a17:907:7f8d:b0:6da:b3d6:a427 with SMTP id qk13-20020a1709077f8d00b006dab3d6a427mr13877780ejc.509.1646756480740; Tue, 08 Mar 2022 08:21:20 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:aa7:c991:0:b0:416:3986:ee63 with SMTP id c17-20020aa7c991000000b004163986ee63ls77280edt.2.gmail; Tue, 08 Mar 2022 08:21:19 -0800 (PST) X-Received: by 2002:a05:6402:174a:b0:415:ce98:9feb with SMTP id v10-20020a056402174a00b00415ce989febmr17171682edx.109.1646756479742; Tue, 08 Mar 2022 08:21:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646756479; cv=none; d=google.com; s=arc-20160816; b=sjephzXCp6gMxmSqQJkY/kUZGzl+QrqibUMDwfkjaHq/HGpXPRzURst84Bzu4heWEF nq1l6SDAgC8w5Lvvnqb5KkDDSgaZSk69E4jlpkJ+s5/Yc+CmYEXyKQmltK7RnpmYZjZX X7ImY9zSqudbiEBSW5NRn4xysOFiiENnP3KGVne4CnZ4fKvwzcnajdGjwe+CFPeE8R61 98Rvb/sxPHn4CxE1bmozNsaLjg+5qsTYf9OYnpBVoN7+cGLdbyb5k8MC8wNZxjASfhQg rmaP9wO+Obn3oWqK/ttn0PAoyMd+z6Sg8k1MC9b3c4TXbY+IGWFqApLlcLNz8gfaQVvH 9DGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=yRYBxD/qcd987HA9xv09I14GYGeFiwKx0DfhQh1e8qQ=; b=Ry2fXLkqGFk7Gt/nSJwyG7P2dh7KBeDj7Gf5t7IaQQjiq3HypFO5/m9IZYMsBg5M/n h448mAWvfm/BWy5V5XXjef1NdNVgkpLg6/d+GlEO3Tz6p4d5+grIffF7FwvUL0lHwKfo 1azpCZ/X+28V72k25kr4QCg45l3eCIuG2vmoLEay30rza+lPRNApsFXV8HczspZqzWtK zRz6UushmmSondr5fjj9QYpXEOQx+1F58prE1xa7UbCYf5nWH1wWoaON51Lwo+jBx+eb rd3R1Pg6Y46EvTPpZn0B2XjwdKKn4m/xZztQd2Uwia2ia9L4chIhh2pq1HGlx+YwusiH 0HrA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id d3-20020a1709063ec300b006d9f7b78412si692890ejj.0.2022.03.08.08.21.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Mar 2022 08:21:19 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4KCgYq3yR7z1s7t4; Tue, 8 Mar 2022 17:21:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4KCgYq36lvz1qqkC; Tue, 8 Mar 2022 17:21:19 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 9TyHLKgq7NyF; Tue, 8 Mar 2022 17:21:18 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Tue, 8 Mar 2022 17:21:18 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 144294541C27; Tue, 8 Mar 2022 17:21:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id rJFQz6SlWR6a; Tue, 8 Mar 2022 17:21:14 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 1E2114540972; Tue, 8 Mar 2022 17:21:14 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 1/4] Revert "ipc_notify_receive: add timeout_ms argument" Date: Tue, 8 Mar 2022 17:21:06 +0100 Message-Id: <20220308162109.383573-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This reverts commit 85b28421eed60c13161ae58cc58d218d5df9ff8f. This will avoid the deadlock when a lot of notification are sent, and the client cannot read the notification in time, causing SWUpdate to block and to not read the IPC with SWU. Signed-off-by: Stefano Babic --- include/network_ipc.h | 4 +- ipc/network_ipc.c | 86 +++++++++++++++++++---------------- mongoose/mongoose_interface.c | 2 +- 3 files changed, 49 insertions(+), 43 deletions(-) diff --git a/include/network_ipc.h b/include/network_ipc.h index 356931b..6dc2521 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -129,9 +129,9 @@ int ipc_inst_start_ext(void *priv, ssize_t size); int ipc_send_data(int connfd, char *buf, int size); void ipc_end(int connfd); int ipc_get_status(ipc_message *msg); -int ipc_get_status_timeout(ipc_message *msg, int timeout_ms); +int ipc_get_status_timeout(ipc_message *msg, unsigned int timeout_ms); int ipc_notify_connect(void); -int ipc_notify_receive(int *connfd, ipc_message *msg, int timeout_ms); +int ipc_notify_receive(int *connfd, ipc_message *msg); int ipc_postupdate(ipc_message *msg); int ipc_send_cmd(ipc_message *msg); diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index 886af0a..eb1082c 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -92,32 +92,11 @@ int ipc_postupdate(ipc_message *msg) { return -result; } -static int __ipc_select_timeout(int connfd, ipc_message *msg, int timeout_ms) { +static int __ipc_get_status(int connfd, ipc_message *msg, unsigned int timeout_ms) +{ fd_set fds; struct timeval tv; - if (timeout_ms < 0) - return 0; - FD_ZERO(&fds); - FD_SET(connfd, &fds); - - /* - * Invalid the message - * Caller should check it - */ - msg->magic = 0; - - tv.tv_sec = 0; - tv.tv_usec = timeout_ms * 1000; - if ((select(connfd + 1, &fds, NULL, NULL, &tv) <= 0) || - !FD_ISSET(connfd, &fds)) - return -ETIMEDOUT; - - return 0; -} - -static int __ipc_get_status(int connfd, ipc_message *msg, int timeout_ms) -{ memset(msg, 0, sizeof(*msg)); msg->magic = IPC_MAGIC; msg->type = GET_STATUS; @@ -125,8 +104,22 @@ static int __ipc_get_status(int connfd, ipc_message *msg, int timeout_ms) if (write(connfd, msg, sizeof(*msg)) != sizeof(*msg)) return -1; - if (__ipc_select_timeout(connfd, msg, timeout_ms)) - return -ETIMEDOUT; + if (timeout_ms) { + FD_ZERO(&fds); + FD_SET(connfd, &fds); + + /* + * Invalid the message + * Caller should check it + */ + msg->magic = 0; + + tv.tv_sec = 0; + tv.tv_usec = timeout_ms * 1000; + if ((select(connfd + 1, &fds, NULL, NULL, &tv) <= 0) || + !FD_ISSET(connfd, &fds)) + return -ETIMEDOUT; + } return -(read(connfd, msg, sizeof(*msg)) != sizeof(*msg)); } @@ -140,7 +133,7 @@ int ipc_get_status(ipc_message *msg) if (connfd < 0) return -1; - ret = __ipc_get_status(connfd, msg, -1); + ret = __ipc_get_status(connfd, msg, 0); close(connfd); return ret; @@ -151,7 +144,7 @@ int ipc_get_status(ipc_message *msg) * -1 : error * else data read */ -int ipc_get_status_timeout(ipc_message *msg, int timeout_ms) +int ipc_get_status_timeout(ipc_message *msg, unsigned int timeout_ms) { int ret; int connfd; @@ -170,8 +163,11 @@ int ipc_get_status_timeout(ipc_message *msg, int timeout_ms) return ret == 0 ? sizeof(*msg) : -1; } -static int __ipc_start_notify(int connfd, ipc_message *msg, int timeout_ms) +static int __ipc_start_notify(int connfd, ipc_message *msg, unsigned int timeout_ms) { + fd_set fds; + struct timeval tv; + memset(msg, 0, sizeof(*msg)); msg->magic = IPC_MAGIC; msg->type = NOTIFY_STREAM; @@ -179,8 +175,22 @@ static int __ipc_start_notify(int connfd, ipc_message *msg, int timeout_ms) if (write(connfd, msg, sizeof(*msg)) != sizeof(*msg)) return -1; - if (__ipc_select_timeout(connfd, msg, timeout_ms)) - return -ETIMEDOUT; + if (timeout_ms) { + FD_ZERO(&fds); + FD_SET(connfd, &fds); + + /* + * Invalid the message + * Caller should check it + */ + msg->magic = 0; + + tv.tv_sec = 0; + tv.tv_usec = timeout_ms * 1000; + if ((select(connfd + 1, &fds, NULL, NULL, &tv) <= 0) || + !FD_ISSET(connfd, &fds)) + return -ETIMEDOUT; + } return -(read(connfd, msg, sizeof(*msg)) != sizeof(*msg)); } @@ -198,7 +208,7 @@ int ipc_notify_connect(void) /* * Initialize the notify stream */ - ret = __ipc_start_notify(connfd, &msg, -1); + ret = __ipc_start_notify(connfd, &msg, 0); if (ret || msg.type != ACK) { fprintf(stdout, "Notify connection handshake failed..\n"); close(connfd); @@ -210,14 +220,10 @@ int ipc_notify_connect(void) return connfd; } -int ipc_notify_receive(int *connfd, ipc_message *msg, int timeout_ms) +int ipc_notify_receive(int *connfd, ipc_message *msg) { - int ret; + int ret = read(*connfd, msg, sizeof(*msg)); - if (__ipc_select_timeout(*connfd, msg, timeout_ms)) - return -ETIMEDOUT; - - ret = read(*connfd, msg, sizeof(*msg)); if (ret == -1 && (errno == EAGAIN || errno == EINTR)) return 0; @@ -225,14 +231,14 @@ int ipc_notify_receive(int *connfd, ipc_message *msg, int timeout_ms) fprintf(stdout, "Connection closing..\n"); close(*connfd); *connfd = -1; - return -EIO; + return -1; } if (msg->magic != IPC_MAGIC) { fprintf(stdout, "Connection closing, invalid magic...\n"); close(*connfd); *connfd = -1; - return -EIO; + return -1; } return ret; @@ -326,7 +332,7 @@ int ipc_wait_for_complete(getstatus callback) fd = prepare_ipc(); if (fd < 0) break; - ret = __ipc_get_status(fd, &message, -1); + ret = __ipc_get_status(fd, &message, 0); close(fd); if (ret < 0) { diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 930cbf3..851a17b 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -173,7 +173,7 @@ static void *broadcast_message_thread(void *data) continue; } - ret = ipc_notify_receive(&fd, &msg, -1); + ret = ipc_notify_receive(&fd, &msg); if (ret != sizeof(msg)) return NULL; From patchwork Tue Mar 8 16:21:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1603078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=ZLrPKhoJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbcxploxj6ikrbaeft2iqmgqey5dgtqi@googlegroups.com; receiver=) Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCgYy1j5Wz9sGF for ; Wed, 9 Mar 2022 03:21:26 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id g8-20020a2e9e48000000b00247bc56d2a0sf6937952ljk.15 for ; Tue, 08 Mar 2022 08:21:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646756481; cv=pass; d=google.com; s=arc-20160816; b=pjoi4xpuI1dHCzio8RnLKaKb6dctTFC4UpynYWLiPFCkcOEwyijHwq8ZRb6ZOAsIxo Va3tyk8Rh9jMCqKCVPMP8ABjqujIk7CdXidm6MWoAtQbvmnfEHP/+yKDdWzFzgBhmlCf p1QffAjERw763B3sRT3nRMUjlBkFL1By0tKAUIbSrAHuTLSjq4dt2xzZfsQ9/coZ4PA9 eIDqCy/7N/Hy+vb2HRaSHc/oay4BwhBygIld77u40X/25K05FecrAWWS0KKmQH0qCFK6 WMutCWPKmKdBu1XH8H86QYUDPeOqBtoa07uvriPyqypvA7CabCZVNhSsrtwLkC1vrmsv 5VCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=g/WJHl2u2EXqJMgmQuJK0QnQsjof7mSkdIJFi+Ht/J0=; b=Qh38ixVso60ChufBWdceuGT/0BuyvzOEtYdYYcaKQLf5SfVi6R8SeOAE+ijxoZrJGy jcIj/G1CmYKnoFlKBWMUwtuuU0wcW9hrmmyupWTd7cYJy3iv8NaO7G2G0CusKFiE45vs f+9mX3xB5jDH91+YclENNSgcq3EOuf/aqetQvshKM3CFWHSdf1gnDT0Vpd1cmMUcSFIq LhvQ0CO2EXDKN8Opr718rxGgqC2oHMEiXcjySJGsrflCNMzCTO6EUJowRYxae605kzA5 MIeZJM87zrnGlvbLjgE0gcMNukkCfJDNPHHfEX9AdsS/5lJStHJjQ8AxhVQqzQF1QQBP OUUg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=g/WJHl2u2EXqJMgmQuJK0QnQsjof7mSkdIJFi+Ht/J0=; b=ZLrPKhoJExkm6liGiW3xL94SyXZ+U43CEVpysGPhjx7+f0kvOmpyhZUtjMta4R/tmt 1Hkezin59UmhS80HigPE/x5iV8oET4jakT/i1OYrNjm1Geu0Q/15k+yKgvz4QmtBTxYI iSsOkrzu2pIPrIZkXe09BVqLxSn25gVPqp43Sh0gcUYMkTuHKGjRLw7Jzx5P+h1nr4g5 benPSq+8FBTXbnwUX7c1m1JOyFDk2AlGHSwIcvXktMxncUsLJV2CHIVz3Sa5TXA/Gki/ i5FKiNM70jBWDUEvTNbRHQxjOvytVFJLF4wbRV/rx8ajIklxdre3ItpSEqgDs9Swz8dV +N0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=g/WJHl2u2EXqJMgmQuJK0QnQsjof7mSkdIJFi+Ht/J0=; b=SqwsOnD0BRtw4DjMA1HnrnE0IYum1WNfPIQfankBjnJNkzGAIMoWnqxpBVZGcCnO67 ftFNNwxkw6x8VoGCS8bubkNR0m+IbzSwGb4z4P+zPWHP4K3xbqcXUE2GTJuskvYfzmFh /YjV2IzoEYQ54MnkS0SkunhtMhAnL0WJVfe1Ue4yUK432RlQdZypAK2qVMVhF/Yzp0VT cm2RBjNzXvSzuaFGRaSArXk/TWkaBiLGXPTrCwX8jwgzYst5LYd7bGAFd/JEvuAJngaA koL6gzsEkM8MqAzV66xmT8ZFXablgMy7u3EE6HDkvCE6YZVP4Bc7V6Y5o6z8U8TZKD+o lHhg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533E2UZ/Qw0p8wAd05nvfxfq9RmKpqGGDEZcfmiIl/Vjik3m4pFO 4PL6KWSoec+kw8dFajg9Fcg= X-Google-Smtp-Source: ABdhPJwvzwPG6w135lJQ5jODn/TxH05BJwDrQ3oHsUcZPIbC5Nggmv/uSYHcLAR5dcMjm38IYJqzHA== X-Received: by 2002:a05:6512:a8b:b0:43c:81fb:8b26 with SMTP id m11-20020a0565120a8b00b0043c81fb8b26mr11527741lfu.479.1646756480736; Tue, 08 Mar 2022 08:21:20 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:1282:b0:448:390c:1de8 with SMTP id u2-20020a056512128200b00448390c1de8ls3328029lfs.2.gmail; Tue, 08 Mar 2022 08:21:19 -0800 (PST) X-Received: by 2002:a05:6512:3d89:b0:448:296c:f30d with SMTP id k9-20020a0565123d8900b00448296cf30dmr8616558lfv.107.1646756479623; Tue, 08 Mar 2022 08:21:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646756479; cv=none; d=google.com; s=arc-20160816; b=fg1rrKP2jj2GMz3UtR+8wLerySYmlkyCwk7SK9cavy1VWNE10cNMU2io/1m+Zm71oz N85xmai6CcDl8/4k5JsRgNAAkJbtUQ00UPNEN4ZidnbHWK8TnYyg9aXRj1W2HBJYUZTs 4meczmmAoGTzfQlY5C+R6k4N938DmGfKmHXRaz8pbgPgkDatUb83lnGZjH41WWAflRmh PoOoz3O3z7wVmq1heYL/ABiOwG7Xh9NDgF+wuw6DXkHTItLG8XxBvLv3L3wgIXaCJV76 rF1TFS2KEeX2BtNNa+uQJwkR7dYQerPwaFgl6aYPIpAs/O9Nwi767eCEeP8JedU7ch2G q90g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=U33NSKhopWES1dQoY/2JWpYPZilkWJs+ja15epcli1U=; b=VwOwMKDj+usZy2eBddmgrWv918paQZrfviOTKP+YjIE0nuKn8DIPAmvmab0200fDqU phWdMS9KnEGOk0zIoUMuvNkWGbinGq6xqjr9el2Kc9A5a4HKc8YaKF2JfFGkeTXRqcX+ A6qzhLcw+Wz/fAOwUdhN3tYL3SrSQbP7Z1ouGLmvv5sbUVrHfFp37FqlR/XfmkSqi4Lp 1R9eza11LpA+0KJiUbrx6xvsW1DOjjXXhbhwimPZo5jrUO0YtjE8gLLIKdFKbsHBsMos GkiPhhfZ8+LoyGbJkupfMI3l2JtzN+hyeo7c8MRAU+DD+txC7iEtX3gJMUPNWdd2JjYE 1gUw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id p16-20020a2e9ad0000000b00247f6f7df5esi118936ljj.7.2022.03.08.08.21.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Mar 2022 08:21:19 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4KCgYp6k59z1qxmF; Tue, 8 Mar 2022 17:21:18 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4KCgYp6Vzbz1qqkC; Tue, 8 Mar 2022 17:21:18 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 8_YhkYnfM5Ju; Tue, 8 Mar 2022 17:21:17 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Tue, 8 Mar 2022 17:21:17 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id C04B54542641; Tue, 8 Mar 2022 17:21:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gj8fAzGjzsdQ; Tue, 8 Mar 2022 17:21:14 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 2B4594541C27; Tue, 8 Mar 2022 17:21:14 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 2/4] Revert "network_ipc: update swupdate_async_thread to use notify" Date: Tue, 8 Mar 2022 17:21:07 +0100 Message-Id: <20220308162109.383573-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308162109.383573-1-sbabic@denx.de> References: <20220308162109.383573-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This reverts commit da6eecfccbf82010d1e47528bb2a9f7e814b7bf6. This will avoid the deadlock when a lot of notification are sent, and the client cannot read the notification in time, causing SWUpdate to block and to not read the IPC with SWU. Signed-off-by: Stefano Babic --- ipc/network_ipc-if.c | 59 +++++++++-------------------------------- tools/swupdate-client.c | 4 +-- 2 files changed, 15 insertions(+), 48 deletions(-) diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index 90c4970..fc5419c 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -37,25 +37,17 @@ static void *swupdate_async_thread(void *data) sigset_t saved_mask; struct timespec zerotime = {0, 0}; struct async_lib *rq = (struct async_lib *)data; - int notify_fd, ret; - ipc_message msg; - msg.data.notify.status = RUN; + int swupdate_result; sigemptyset(&sigpipe_mask); sigaddset(&sigpipe_mask, SIGPIPE); if (pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask) == -1) { - perror("pthread_sigmask"); - exit(1); - } - - notify_fd = ipc_notify_connect(); - if (notify_fd < 0) { - perror("could not setup notify fd"); - exit(1); + perror("pthread_sigmask"); + exit(1); } - /* Start writing the image until end */ + do { if (!rq->wr) break; @@ -63,32 +55,17 @@ static void *swupdate_async_thread(void *data) rq->wr(&pbuf, &size); if (size) swupdate_image_write(pbuf, size); - - /* handle any notification coming */ - while ((ret = ipc_notify_receive(¬ify_fd, &msg, 0)) - != -ETIMEDOUT) { - if (ret < 0) { - perror("ipc_notify receive failed"); - exit(1); - } - if (rq->get) - rq->get(&msg); - } } while(size > 0); ipc_end(rq->connfd); - /* Everything sent, wait until we are IDLE again */ - while (msg.data.notify.status != IDLE) { - ret = ipc_notify_receive(¬ify_fd, &msg, -1); - if (ret < 0) { - perror("ipc_notify receive failed"); - exit(1); - } - if (rq->get) - rq->get(&msg); - } - ipc_end(notify_fd); + /* + * Everything sent, ask for status + */ + + swupdate_result = ipc_wait_for_complete(rq->get); + + handle = 0; if (sigtimedwait(&sigpipe_mask, 0, &zerotime) == -1) { // currently ignored @@ -98,18 +75,8 @@ static void *swupdate_async_thread(void *data) perror("pthread_sigmask"); } - if (rq->end) { - /* Get status to get update return code */ - ret = ipc_get_status(&msg); - if (ret < 0) { - perror("ipc_get_status failed"); - exit(1); - } - - rq->end(msg.data.status.last_result); - } - - handle = 0; + if (rq->end) + rq->end((RECOVERY_STATUS)swupdate_result); pthread_exit(NULL); } diff --git a/tools/swupdate-client.c b/tools/swupdate-client.c index bddcc86..7ddcdcd 100644 --- a/tools/swupdate-client.c +++ b/tools/swupdate-client.c @@ -85,8 +85,8 @@ static int printstatus(ipc_message *msg) { if (verbose) fprintf(stdout, "Status: %d message: %s\n", - msg->data.notify.status, - msg->data.notify.msg); + msg->data.status.current, + strlen(msg->data.status.desc) > 0 ? msg->data.status.desc : ""); return 0; } From patchwork Tue Mar 8 16:21:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1603075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=J1Hqjk+6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::140; helo=mail-lf1-x140.google.com; envelope-from=swupdate+bncbcxploxj6ikrbamft2iqmgqesmvgbsy@googlegroups.com; receiver=) Received: from mail-lf1-x140.google.com (mail-lf1-x140.google.com [IPv6:2a00:1450:4864:20::140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCgYx1qhcz9sG9 for ; Wed, 9 Mar 2022 03:21:25 +1100 (AEDT) Received: by mail-lf1-x140.google.com with SMTP id q20-20020a0565123a9400b0044849a1072bsf551461lfu.4 for ; Tue, 08 Mar 2022 08:21:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646756482; cv=pass; d=google.com; s=arc-20160816; b=BghsSvR8jDuSuNilKNtDqKL8ErpQWM+6cHj760sHXzQwY6NnkI//Exvx6WVrMWzbVx OGc89KiAQCjzNinHEWKFDbGBIdAYdHbe6hFTmhzJ3E74DDTWYKir2JCLASMmXhDAtpkL 0JL9MnN98n+bzvFsLLaiBbLeC40f+8ASrUE3vbjl0PTsCE1Kfhg2xA8rYGEcS6S+gzUZ PD5X0dNqq6+xrGtCGeXgyJJbTVEwaHicM55xUVLdBCt2AwRCkMioR+Mya3aQ2JSj7Ba9 UcDXUYoGBfCDM5i0+Yz2XHistkF/IToU9sidpTcNBcpyw/b3SCeHuCiZJ3CS/tt3/lmY JnTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=UorDlmyQkehuGJgnaE9JH8JlBxy7Q8xrv7aq+iZiVoM=; b=FwG+Ci+LnfKzLXvb+vTUelLm4J+W2RRN7oXMH9ah34e0DJpW23wOFP6ccuzYDJvnvF vbMvKbbeXUsh2FHTJBwwxWi6BkobtrzsWOUJ7O4f04r+O02f0PB4hUaIH9hfkpK7Q69i TMHjzYrUpKSAM9ABt6UwQydw+LcyYe2iqkkD9zm4uwPoCyULuusEr9EjjHz1+9044yhm 8110g58mXv4WMKVAHqZ1lq5t0hUhRJ/DUQGJYpndfymH2FWwBr1fXFIw6pNM1Kz+Pkaz v0mIbsqNwZI8wZ/4YMoFeTesG7dYhnr9K0YqB9D8yXL3p1C3hL6Eqk/fZv3THi41U2xE jA/g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=UorDlmyQkehuGJgnaE9JH8JlBxy7Q8xrv7aq+iZiVoM=; b=J1Hqjk+6YWmKEya0QPeqG9hqOvsBMNH9U43xqZx2rrpdqANP2b1FyYe0BEJxEHm2LE EAAbcFauJ750GICVN2Q0LM8Ddj0uxCjF9yO+iCgfaCm00ALmHTGBcXHH9YAuGLFX+Y/b 3NsPQi9jFOtpQJunTX3ildho1EqnSLmoTKwN5l+deTsXnPjJTwLBpG/PpRx+at0NsjhG nrXySvHd4vJoNPXzKFOxOk0kaXr2vOBh7rHWWg6kmFVYlHEebN43st5jxRCye8QkkboJ ahXBiTmyeAvNTsDSMKcNG2DLPuIgwMvMuMnU5pxBfww8M9YPEYYAYcNrOeDJoBByqEJU JJSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=UorDlmyQkehuGJgnaE9JH8JlBxy7Q8xrv7aq+iZiVoM=; b=JS1fQ3EfcdS9bzFojKldfCV4WZ//h2uNHfCHx7MhOdGSelTGXZdA+K79ERJLi4ie6y pFYNpw+ZotJ146N5DUcMCwtVhdKPagCU4V1l15I8jQIC1MsVtEOXZrqpdrIny1LEpRa4 WuW7tr87+cHUJXp0LFpKeFmvEUpJiJIy/Po790pU6Z0H+k7BlZhQtrK9i1aBms1DSIBH o0DNszMGIMNs2GE7kErCQXqhZx+VuOv6TyT4wrXv/ca/wvTZDvQI1wnL67bE91DgxCgy wSqHBqGZoI95ivPP2sRhn0Cwy9TKi3nsslciSBSFl9bO5SUM16wAXBjmzkQiV1MLS+Dr dU5A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532Yub1qODShcNraKoluixapYN4vGW58cTRG26XW1jFbTE35xb78 Ni97Qb3AMzfRhmyRfxLT8GU= X-Google-Smtp-Source: ABdhPJwtKrdfQt6rm+4Fat0bBec0yqAq+eSP6U6Scf9uIZx4yd6QDacoY4H8O51ckQwvko0T+hESEw== X-Received: by 2002:a2e:a372:0:b0:247:ec7f:d458 with SMTP id i18-20020a2ea372000000b00247ec7fd458mr3468894ljn.275.1646756482021; Tue, 08 Mar 2022 08:21:22 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:1693:b0:448:3742:2320 with SMTP id bu19-20020a056512169300b0044837422320ls3468368lfb.1.gmail; Tue, 08 Mar 2022 08:21:21 -0800 (PST) X-Received: by 2002:a05:6512:3ca8:b0:42d:e83:f0e8 with SMTP id h40-20020a0565123ca800b0042d0e83f0e8mr11397969lfv.425.1646756481002; Tue, 08 Mar 2022 08:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646756480; cv=none; d=google.com; s=arc-20160816; b=n6FpVAONYzQqIiX23t5OwgWnItFGL2PicNge51PqJinA0JhRJpyXY+oWZSQ2J1Q7fC nq9plq5nWTD6GOVuqtHCJ6QPEx7giAFLZNeXR/jcHL/UwsXrT9TbhDWcUcujzbOyLGvL Tv7cpZ+/k9uc7n3bbeQyn3wirSSvJMbQmCtB/l9oQK/JSZ4MMejubcxRse2ET50bvN1A eiHHu2IzToRMGoULWxv2TCYvTHWVETDNOR/a26ZpbIPOWaOGfcINxNH3USCHOA3HeIvl kZQGRhE6ulySDcFGbM0v4ZwAVTbzqMTvf3msv6quhqo3ahwoHrecIiVDb1miV3fjtn/Y H/eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=CvtjTGQ9x4igNrNHbH20HUoppkGRWt+cSdCW9a6Czb4=; b=YWLAZrn502vJdtsaBWuV/xGgA6txbIS93oVLd0hQrCokNnP7mM5Oktvl5G1clP7PzJ wiBxWv+fc1oPmg1c6UZlGmhn92ZgMO7LEeE8+69m133DfvyxiQp4hCap7lW1hncCBx5J zjzLaxRd+xqGVttSy+RrYpm/YDfa2iAHQ4qF9eEo1qKCeGJ5HZmIbanB0G3foR6uvQHw 6JNCnYfR7YOyT6o9CO9fhNNVlum2BwR8JABIVwkjIyYaoMxukGYiHi2W/Oaj40u34IkF 7syfrt1tKq84Kzex+qKrE5L9yg0JNzoOkZh65JR9sngo8Y2JoJIZA4e3J+cejKDMNQ7v 6jbw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id u7-20020a056512128700b0044826dbc513si561748lfs.8.2022.03.08.08.21.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Mar 2022 08:21:20 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4KCgYr3HWFz1qy4d; Tue, 8 Mar 2022 17:21:20 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4KCgYr33jYz1qqkC; Tue, 8 Mar 2022 17:21:20 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id LvzLwlc4i3pQ; Tue, 8 Mar 2022 17:21:19 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Tue, 8 Mar 2022 17:21:19 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 767D84540972; Tue, 8 Mar 2022 17:21:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 4AEADl9wAmIs; Tue, 8 Mar 2022 17:21:17 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 39E9D4541ECA; Tue, 8 Mar 2022 17:21:14 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/4] BUG: IPC: ipc_send_data checks data is sent Date: Tue, 8 Mar 2022 17:21:08 +0100 Message-Id: <20220308162109.383573-3-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308162109.383573-1-sbabic@denx.de> References: <20220308162109.383573-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , write() returns the number of written data, loops until all data is writte or an error occurs. Signed-off-by: Stefano Babic --- ipc/network_ipc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index eb1082c..d1cb3e5 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -310,8 +310,17 @@ int ipc_inst_start(void) */ int ipc_send_data(int connfd, char *buf, int size) { - ssize_t ret = write(connfd, buf, (size_t)size); - return ret != size ? -1 : (int)ret; + ssize_t ret; + ssize_t len = size; + + while (len) { + ret = write(connfd, buf, (size_t)size); + if (ret < 0) + return ret; + len -= ret; + } + + return size; } void ipc_end(int connfd) From patchwork Tue Mar 8 16:21:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1603076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=jjLLzozT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33f; helo=mail-wm1-x33f.google.com; envelope-from=swupdate+bncbcxploxj6ikrbauft2iqmgqebmxhcna@googlegroups.com; receiver=) Received: from mail-wm1-x33f.google.com (mail-wm1-x33f.google.com [IPv6:2a00:1450:4864:20::33f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCgYy0fQVz9sGD for ; Wed, 9 Mar 2022 03:21:25 +1100 (AEDT) Received: by mail-wm1-x33f.google.com with SMTP id v125-20020a1cac83000000b0037e3d70e7e1sf1376360wme.1 for ; Tue, 08 Mar 2022 08:21:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646756482; cv=pass; d=google.com; s=arc-20160816; b=eQENDycbRKI7trZMaVkCgbCDPV+6p+g3svcrkxXfvzCmiO7i5Vk4pAiKa2bwNsg4xb OscsE8qslvKqqQGAuvnoCaeCI/7aAwZF2y1NmI84U65d16mJENwTLeCHBAz9bSc13BlW S+Cu7w5Ma5ZVJdi08yGX8drd4JhPky7ttk4EsiSfatOYWXEQwVrYwwf8HyuELOBej/8W nmpUQz9s/vTVaDgifzXgburr8maniQVwSCKjcHa50qY+Vt6NntskDnzLKzh2mzFVeVuS Glh48xXTQgoz5kNHc+H0FgzkZjvAapx13TUXar+DFEgCUzl7x8RcPHUQXuMWkMbFtBJq hLkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=fm7q27jpTq1Di73AXcAmDLl+TQD3ckFTpbby9wZux40=; b=dQ6ZglQgDPgIejGBfYZp1QOMxdi7FOu1fBMKWz20RRVh/u53nx8fklfQt+jOE6EHxb Gc9xVoKwphnycwBK9cePw/9Vw/FepdGTaCLqRyGzpQONEet2eQgn+rRsDTft1UdmMqrJ wxZtqJBY99lyt5lCkc4XyM8tufkm7pAZMi5ubOe32UwjDSNpyqchjP4ySNoyixyL6chJ x2ky+a1nuxEYRFoPzc6V98S+9Xy4jr/nzVd+Wp7fXJ8sUlk/2sWMATgw1bTycC/em6EL V+nhmR1nYpLZGjibnDmwLtm2gOzUpQLc4T44TWFqHipLwgPNtbo6pYMSw71B/guyX0xJ M8vA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=fm7q27jpTq1Di73AXcAmDLl+TQD3ckFTpbby9wZux40=; b=jjLLzozTxCgVCOXZoEx4N7MewCSRlnyLSXX3IBsdrf7ZL2NTqolR7OswROSLbxTt3C VZxuc1UHenoHcQyNTzoBB7yd18oFPhpHlqi6aDcjwFmBM/dvzCEOfvAB1eKYqt+MURHm tXeLjGrBtAU0g9Gw5tr9V1Xjn/4U3dR/2OTBuZWjFhNZzRttgf6r0uJJDuRmWtZZ9GfU vrLSo9HCdfefa3ZTGLz7MWLeayuaQUJ87BOgXZttY6yGGSdgymOVeGpiEju3Skxq/i9w NCWzB8kv891LV8XhwQlYPPDZas+PLCm51QYT4F4NA4GK3o2aTTFSBFwOYQWooqGPXB1+ 1Mow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=fm7q27jpTq1Di73AXcAmDLl+TQD3ckFTpbby9wZux40=; b=ZaEvT+edUfu1vZLVmnRbu5IuPkpi5afT+5RLa9Wk15cqE3Nc6iYKO8IHDfz/4YMbp1 24jh5otU5zMK6D9p5AUBZbzYH8dW0/zH4vQPVSg5VOupl0GCNarCh/Mj+OW2VmQQyRZy PqGUXMYD89h3T4mgDRGwrtqdUynn2pBjMpiHPi644nKiaX9XhihFbaTID1+FnBDyZDSp 9Zwa3H0QPZvjQh9FAkh521j9eYzhfXklqkmu4IwDNLu1locRJ4QGNzmI8zJj+ShxB72N N1xCihSeKeFyVHd0NT7axwVyqVykwhmRUN7213B8VJ4wFvqEWeSjgOfzIIppa4XBRLiu Qzfw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531SoK8VmfqHAsp8kRmBE9D5yQeMasy2bcterd3g1GO5OcF1MM+E jWG+hFMeZf9hI1sw78+Uvx4= X-Google-Smtp-Source: ABdhPJyFnYAenUSc3iBlLywoRHmlja9AauXttbmTz3R2FyBfXrHqVNUdOmz4WLb+89JruuxqKBivDA== X-Received: by 2002:a1c:540a:0:b0:382:aa24:dfc2 with SMTP id i10-20020a1c540a000000b00382aa24dfc2mr4311121wmb.42.1646756482456; Tue, 08 Mar 2022 08:21:22 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:790f:0:b0:389:cf0b:4f92 with SMTP id l15-20020a1c790f000000b00389cf0b4f92ls95372wme.1.canary-gmail; Tue, 08 Mar 2022 08:21:21 -0800 (PST) X-Received: by 2002:a05:600c:5108:b0:389:b089:291 with SMTP id o8-20020a05600c510800b00389b0890291mr3617wms.109.1646756481557; Tue, 08 Mar 2022 08:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646756481; cv=none; d=google.com; s=arc-20160816; b=JVGhIr31hkNPD7HyAYtGeF4XTSf2OCVhJc9zKrJfsuuoXS1OtfwQcsJsBqjXtacqEj Wi/pm8nKx0Quahn95OA2NAD+LBAS6W/lJIT5/tOpHRuKHJKkExu8GO9oc3oQ6ybzQCLb ftPHlb73XAf89HHnnVDLLqeSE1UbL6bWu8OL19ue+I/ZOdDbkCxPFS0sXHB/fg1nAeMY qBst8rdNC3MbvdrpKksrRzEtxHcefbB01T7VjrQgpv73AFTYm+0HOJvCcCAA4Hk4Ou1+ BN89ZDDqB5t7CxNn/hQwBr2T0NVr2jAmOQHc1OGd2sLhPHRJC0r6ND9RICzstMlxL8f3 9+Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=61r2maUhTJlZZZCcisw4+hnjplJPXPlnOsESGFAPLgg=; b=L0ex6AGiF9tVa0Goi9WEW121ttTh91UuKN0xysEuUgCs6nNimcxwBFTpXMqc8PCuMD 6KEYzEV4S/HYAD9WmNk6jJiW6G+SBV0eKFDWbEaHZDEOHwtDoh5aQKRBI7Dzw/Jj4t3a TP2hfGylLDGSTAsOEqmKDyxLU8S8BmDH8qY2AOHjnUB/ZnAFdRhKvAwraNhAwsC+Pela rqO5cU7z0Y7Y3u1WF5AHVymOL1aQmWdogJ2aUTL4mqS3V2697FRmOSXykC72myxt2M2g VrXAQIHr6Xb25KJAnPWQIwzmzSKhS5jAUxnLfNG8A5CcLEcJX11xT4GC7pXf0ku7cXcq VYZQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id i12-20020a5d558c000000b001ea830df1aasi958804wrv.7.2022.03.08.08.21.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Mar 2022 08:21:21 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4KCgYs2D5kz1s7t4; Tue, 8 Mar 2022 17:21:21 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4KCgYs20X9z1qqkC; Tue, 8 Mar 2022 17:21:21 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 4fKu785L1REt; Tue, 8 Mar 2022 17:21:20 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Tue, 8 Mar 2022 17:21:20 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 6E0C04541C27; Tue, 8 Mar 2022 17:21:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id eHMeTDs3Q7sA; Tue, 8 Mar 2022 17:21:18 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 4B68445425EA; Tue, 8 Mar 2022 17:21:14 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 4/4] IPC: do not call exit Date: Tue, 8 Mar 2022 17:21:09 +0100 Message-Id: <20220308162109.383573-4-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308162109.383573-1-sbabic@denx.de> References: <20220308162109.383573-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This is a library, returns in case of error instead of exiting the process. Signed-off-by: Stefano Babic --- ipc/network_ipc-if.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index fc5419c..c8a6cd0 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -43,8 +43,8 @@ static void *swupdate_async_thread(void *data) sigaddset(&sigpipe_mask, SIGPIPE); if (pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask) == -1) { - perror("pthread_sigmask"); - exit(1); + perror("pthread_sigmask"); + pthread_exit((void *)-1); } /* Start writing the image until end */ @@ -53,8 +53,12 @@ static void *swupdate_async_thread(void *data) break; rq->wr(&pbuf, &size); - if (size) - swupdate_image_write(pbuf, size); + if (size) { + if (swupdate_image_write(pbuf, size) != size) { + perror("swupdate_image_write failed"); + pthread_exit((void *)-1); + } + } } while(size > 0); ipc_end(rq->connfd); @@ -97,7 +101,7 @@ static pthread_t start_ipc_thread(void *(* start_routine) (void *), void *arg) ret = pthread_create(&id, &attr, start_routine, arg); if (ret) { - exit(1); + return -1; } return id; }