From patchwork Fri Apr 22 23:59:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1621287 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=QwMmEPpX; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::d3d; helo=mail-io1-xd3d.google.com; envelope-from=swupdate+bncbcwivbv7sugrbb4drwjqmgqe7ls7yma@googlegroups.com; receiver=) Received: from mail-io1-xd3d.google.com (mail-io1-xd3d.google.com [IPv6:2607:f8b0:4864:20::d3d]) (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 4KlWcT65Fzz9s0r for ; Sat, 23 Apr 2022 10:00:09 +1000 (AEST) Received: by mail-io1-xd3d.google.com with SMTP id x16-20020a6bfe10000000b006409f03e39esf6444499ioh.7 for ; Fri, 22 Apr 2022 17:00:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650672007; cv=pass; d=google.com; s=arc-20160816; b=LpT+9toKZC9RPdI8uy444r98nD8QtXvWQdDgFJ0sg7CF1l5N4CuzxJGCh7ycpvwEVl TzZXCe1D9h9MxpSyDollDYPGENFtwzRADDQu2MVv6kmMWlWFZB52U5u5LJiSXHtZr1wO fsPkmkW4O2olP4Oo6/lQR3G/H5OEhoS2Io1LWZt+/wRM//tHa/nvyDlExop+7rvxGkFQ jCLUbrnpRoYHwE2ep7xuU21Ve4myjFGDECZSQ/jxT8PPfStrP5hQB5CyzryGWKZ+7z5A vNnhtwg18m3L1sBBRyhL150+VGWjnzQqmXSF1HFSDvebB5kghXDMzXCjsH6p8r+qRRx2 K0ww== 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=IJRgYQ141oQT9GfBBXc9/lqq6r/QiGa4e7TIF/GX1Dw=; b=kDocy57iARWONewsym296j25GKRNZ0zMPzXFC52l+wBwDicZaaNZpF7wOwHpf4OboG r0oNxqcShFSHjYg/64NvVLtSkog9kZ2f+Sszs19VnnxbI736FCnXpGikNWzvXcIzxw6+ PpK6ziGZQldczWr9TMP/4xAhZ/7Bhwmo2nRcUz67+JTXUYdAXy2pMTGt+IsEuuYbEOtq nYpeGylItygtXiNev+gF9hBwIl4bhzLBRlveTQGkXZqeele4HcmVm4VJqbBAdJd6yljh iVaVMCQFTXzAhAOwLpkYp9/JC99LV+aNNB+3umoTUs2W7y4xcnKgX5tIeYtL3Jkd5R5c +DWQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com 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=IJRgYQ141oQT9GfBBXc9/lqq6r/QiGa4e7TIF/GX1Dw=; b=QwMmEPpXV6ComgNq6Tr8EKo3Qiv4Y1d0b7tFBaIIwgaGXhFyjA2jupZsyLLXjoRO+k +1pAip5aJtP5uYXX1K16wUWVh0oW9zQQ1T93Dg8eOcQvA833KhXWuW3ejNzqFUUIukFI fydhcRWToKZ8FL74jfz1vMmmT2nGC9kftENDcxtaRx+4GcEThvbMk1nrWib6ZTWtMZsu 4JhHdd/HCjxpK5ycjwX6n3ZtRYb2+KVa5BeZLdjbJj6mY4rHf0i7l9bvLzLoLq7WqbH2 +lz8diiWc+QTosnCKJE9vwwwa14EDbzpQ48YhmO0hMWMxR1Pypmu/TvCdGIiAz6bt9pq feuA== 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=IJRgYQ141oQT9GfBBXc9/lqq6r/QiGa4e7TIF/GX1Dw=; b=1WgmaL+TUwaqRWwUQ+OWhfHy+8h7bzEGKxEtTCHNRskxVV40fLTgEUygMeQ45/GwAv qdcyLTs+vN1nxdUbm2yL5zKC+kXLuahbdUOgJekeJQ599cUNv1+Ux/l/aiy9OXmNh6QT hpofia4Fe3Y1t+CSxpLHaXKW8wH0EqXBL9ZmRPdpfEpLJcoztdtSxiWIMyjil0sRVLh8 SjGXejiFykVn1PGWZhF7nhn+zrIsRHn5Yi3nZB5C0p8uVt89n1qhJh35Q9Sg9DTMmmev SzDL+lOJp4teNlHor+RS6A2BNC8i1NYq7lMMsJxADXRwpM8qaY2SYEJCNT8pZskUFJuZ 3HBA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533ygJ7JA9FTjBnd0+IH7Nz3djPTY0VNprplknG9fa9HbjKccUUi asd0i19ykDK1++oiLdUXckA= X-Google-Smtp-Source: ABdhPJxtSU1Q9UqUsAZ3WzugC94LFHjRe8qxcp8X8XFZ+MDT5u4fvHjRbyKxA4A50Zw06e87LXmgTQ== X-Received: by 2002:a6b:e918:0:b0:654:8aaa:abd8 with SMTP id u24-20020a6be918000000b006548aaaabd8mr2988388iof.57.1650672007474; Fri, 22 Apr 2022 17:00:07 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a92:c563:0:b0:2cd:7bd6:e895 with SMTP id b3-20020a92c563000000b002cd7bd6e895ls606863ilj.5.gmail; Fri, 22 Apr 2022 17:00:06 -0700 (PDT) X-Received: by 2002:a05:6e02:12e7:b0:2ca:b32b:f011 with SMTP id l7-20020a056e0212e700b002cab32bf011mr3006964iln.284.1650672006887; Fri, 22 Apr 2022 17:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650672006; cv=none; d=google.com; s=arc-20160816; b=RUdu59gAXIdXYx/hqNuGvvFt0Xxw3nzdPpAfK4hsQlXa4sNujXQlk6WXlZxG1m4YW2 XCnovX90CqsJ1SWHr+luFfX+jNzboQPWnyWW3c0MgKkCK6z8Jko/Nm1WY05ojIJuV7j+ H8ri6BoH+VP1dTx4ONzk/tklFs7GKAqfgcu0VxRNr/9HLASvV1S4LKo2zrL5NAdFmRwA iC33WkxZbt1U0PHg1b3NkabeGVlA4I+9Q/ing00ELf5rKkUGNoUSDiQeCPP9eGLk1ROB VyUl9ebutVLJbI2pCeKGgCDnYTsXVKoxhrUl3rMkgZlJXb7ouMojuAxjSw4oEHrq+QKj H7Fw== 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=K+mhMMPSkK81/BV0c3/1/AbnWTd+RL8UExmrC72W1J4=; b=lgSV88UIy8NqVsiUZh710ai50SvuXjGWArIg7AEPTEX9ObTE1HAOBLc12cwkuvj1GR kRh8nw3u0cwkR3IV7/4PYjB1pkV66e3HemAgLy7XTtCxq4wpQlO5kxJezakQTGMWiZXZ sfrpexw3ESdWzb8WM8insgyTdG2a8u8t9eCZMGVzSNm/IEgnb8JTJWzZcE95nu9NljIM bO+KaYTJXk+QEuFd8GGE17B5DNBC1S3tFIIbL4Wh+XnGulk9We2L/Mj0zGCu3SC56B7O nzDavXZ3/nC/7MrMMxNn1ZJx0Pit4wMlKh9U1WcXv71mcdTHcaHAStsIetthcqfwM/Qh s5tA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id i15-20020a023b4f000000b0032660e40519si542895jaf.5.2022.04.22.17.00.06 for ; Fri, 22 Apr 2022 17:00:06 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id 06CDF20D56 for ; Sat, 23 Apr 2022 09:00:05 +0900 (JST) Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by gw2.atmark-techno.com (Postfix) with ESMTPS id E693420D56 for ; Sat, 23 Apr 2022 09:00:04 +0900 (JST) Received: by mail-pf1-f198.google.com with SMTP id g5-20020a62f945000000b0050578328060so6305712pfm.17 for ; Fri, 22 Apr 2022 17:00:04 -0700 (PDT) X-Received: by 2002:a63:1252:0:b0:39d:aa7a:c6e1 with SMTP id 18-20020a631252000000b0039daa7ac6e1mr5984548pgs.436.1650672003761; Fri, 22 Apr 2022 17:00:03 -0700 (PDT) X-Received: by 2002:a63:cc0b:0:b0:3a4:90c:ded4 with SMTP id x11-20020a63cc0b000000b003a4090cded4mr6066662pgf.260.1650671992715; Fri, 22 Apr 2022 16:59:52 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id o19-20020a17090a421300b001cd4989fec9sm7313925pjg.21.2022.04.22.16.59.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 16:59:51 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1ni3Bm-00BmZN-7o; Sat, 23 Apr 2022 08:59:50 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH 4/6] network_ipc async_thread: fix hang on failed update Date: Sat, 23 Apr 2022 08:59:42 +0900 Message-Id: <20220422235944.2808227-4-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> References: <20220422235944.2808227-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com 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: , if a update is large and fails, it's likely write_image would fail. Old code would just exit there, quitting swupdate but a recent cleanup made this just exit async_thread without calling the end function, so the caller would be left hanging waiting for an update taht will never finish. This can easily be reproduced with a script that exits immediately with a failure code followed by another 'large' file, with swupdate -i or swupdate_client Fixes: 626d83f8819d ("IPC: do not call exit") Signed-off-by: Dominique Martinet Reviewed-by: Stefano babic --- I can provide a failing sw-description if required, but basically a cpio with - a small script that fails immediately - whatever image that would be ignored fails reliably for me ipc/network_ipc-if.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index c8a6cd02c72f..bf946648edcf 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "network_ipc.h" static pthread_t async_thread_id; @@ -44,7 +45,8 @@ static void *swupdate_async_thread(void *data) if (pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask) == -1) { perror("pthread_sigmask"); - pthread_exit((void *)-1); + msg.data.status.last_result = FAILURE; + goto out; } /* Start writing the image until end */ @@ -56,7 +58,8 @@ static void *swupdate_async_thread(void *data) if (size) { if (swupdate_image_write(pbuf, size) != size) { perror("swupdate_image_write failed"); - pthread_exit((void *)-1); + msg.data.status.last_result = FAILURE; + goto out; } } } while(size > 0); @@ -69,20 +72,22 @@ static void *swupdate_async_thread(void *data) swupdate_result = ipc_wait_for_complete(rq->get); - handle = 0; - if (sigtimedwait(&sigpipe_mask, 0, &zerotime) == -1) { // currently ignored } if (pthread_sigmask(SIG_SETMASK, &saved_mask, 0) == -1) { - perror("pthread_sigmask"); + perror("pthread_sigmask"); + msg.data.status.last_result = FAILURE; + goto out; } +out: + handle = 0; if (rq->end) rq->end((RECOVERY_STATUS)swupdate_result); - pthread_exit(NULL); + pthread_exit((void*)(intptr_t)(msg.data.status.last_result == SUCCESS)); } /*