From patchwork Fri May 6 07:37:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1627425 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=Bu/QKUqH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::83c; helo=mail-qt1-x83c.google.com; envelope-from=swupdate+bncbcwivbv7sugrbp5a2ojqmgqek2abzii@googlegroups.com; receiver=) Received: from mail-qt1-x83c.google.com (mail-qt1-x83c.google.com [IPv6:2607:f8b0:4864:20::83c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kvj8M6Hhlz9sGC for ; Fri, 6 May 2022 17:37:39 +1000 (AEST) Received: by mail-qt1-x83c.google.com with SMTP id r17-20020a05622a035100b002f394e60eb0sf5437572qtw.5 for ; Fri, 06 May 2022 00:37:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1651822656; cv=pass; d=google.com; s=arc-20160816; b=qZ/zH8qIsEUHpEFFH1Zt1xIGCBDpDqJh2tUB+Fa0IrTfHd67BcNomQYfkauHBgTtfw O5nvWPSS/xSR+B7raL0vatv8QiJ9b8KKB1mgmxOhOGVKVGyFptCctn0d1kFY8m8LCxJB 30R/f7hecITMnh6surM5lrcpQmpuwHVQWlgEo5Yt0iSGZXSKdM5ymuRGLc72Zd8gJ3ae +KB+3xiiUR9A6RzEiqPH78eTRDpPzgRNzdV4Gdphh9CJtNLCnWv0f+9YtiwImuvGrXfL JKuYR0j+Y4lsOQRpOKaZhRvySqbpYrWpNYFuvFe5lmqu/xRKr6ZBcYMw+b2xVa69Ptr+ Z3+g== 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=BNNIXiUx4gkB/jkZd7Y3gHlpIgkScLLbTkI7qcCQr+4=; b=Y4VDIpv4N6xfaHA7j+LtQzqr3avSMLWOTYj/D18BAa0B4WkMcOiXxXVxGNmf6/HHpF tYrUt5Ov3N6U1Z/JfgIIydGTPEr/w3ZYi4WaYph232FbxJSoLvDwrfmvqURtEvJxybzU MSirf3D0ok7C3PcPL4Fq204QZ2yqCzNaUtLjOnd/HNhfz1o0DlcMd5K3aUz+hjPhecAn mvsW9V22NLIjo5fSM6tMEvfu+XIc4/51B17achpfozPKnhg/Lb9Lxl9gp9YA2jh7Hc8/ ogc/HwBk96tJNVYdI2b368msCWZObzWlNJ4X4JKGZE+76cMivnn4xizKhly3SvXIg3Za mPXw== 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=BNNIXiUx4gkB/jkZd7Y3gHlpIgkScLLbTkI7qcCQr+4=; b=Bu/QKUqHGCS4PeT8NlvTT2NHBgialWkiLTQdyJvrcE7mtMfWDBebhNF2AYbTlUvZg+ Z12qSJ1EJCggukBD01rIzQz+0nRCDJqXT/MzUgXq+ZskwLeRerKgFHnudrRFRv99F9q9 CVaDHp2/Ou69o388twE0vovWkSrfUO38RJNIVob6ATqe1RBaXnaKcD6ENNnBhY8IINLA kQR43DAXoZs/Oi8vzuXvuARzsN7eXtbXELsUXaGOLCmcjoPqtpKZxRNc1kPKjEGiOZFO qNlrfyNhcmmaTQ4jIxr4w265X/p8Ut3moX/s39q7J/KJLhOGkZXt6egFk4TpijnBNQl9 4lPQ== 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=BNNIXiUx4gkB/jkZd7Y3gHlpIgkScLLbTkI7qcCQr+4=; b=ZHkG5mr9U+NyuUr8cIc3N5oJ/EAZOFm93PgQeoFWlVazvWm2Vwc94JarRjFddGJLiL uOJm6k8ddveNCq6aw2NWOQ/lCtnTeMtigrvDJbKMblT6TBEPbPOGFEQM5DKV080lWiDn TcMt68GWSeBh1+FDs7u5GB9Lj7pecmTqRcXTrfPF0y5yRq8F2BUTBZksh1cvVFXmB743 I/0Fx2JEGfq7+SRlWmmzIqYYNrQ/Sudc5uuJcfkZHDTU4PJk82/bNdvnnRM2a58T7H1+ kVqUocwMSNtY6rZJbGxuQRk2FDU+wNzEbwNtqQZhfp6B0Hpd3dsvXefPLmARYhU2MkCv EeAA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531bm2qJs55sRg99S5wjUc4LPYD5Zaxz7tsJuN/H2VjUcMLWsD8b 66KJuopNIesXSO7U3sKqnmc= X-Google-Smtp-Source: ABdhPJzxbxoNdga/GoySAD2vXZtQ74iSXz7hBLuQTCqUxv/fYa1B6B5aZFeD1urZk9kPaixUOhuBCA== X-Received: by 2002:a05:6214:21c7:b0:45a:bd13:f172 with SMTP id d7-20020a05621421c700b0045abd13f172mr1430030qvh.40.1651822656013; Fri, 06 May 2022 00:37:36 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:622a:1b9f:b0:2f3:c6f6:999d with SMTP id bp31-20020a05622a1b9f00b002f3c6f6999dls559030qtb.3.gmail; Fri, 06 May 2022 00:37:35 -0700 (PDT) X-Received: by 2002:ac8:5a82:0:b0:2f3:bac5:6158 with SMTP id c2-20020ac85a82000000b002f3bac56158mr1565957qtc.57.1651822655255; Fri, 06 May 2022 00:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651822655; cv=none; d=google.com; s=arc-20160816; b=Wl0Pbcl9BXVCJ14n15WM7ru2rwE+VW567h47O1bpTQMs4B7uUQNzc3D9aL7CtygSoI 6BUEVZpqmAMKBqK56LRQAlVHPm9KcUz1FwVBrJN1XexPPWbuTx5Mxghd8pdoLG4Lju9b T0xKMiooJtS4NlBvaKZHTVtW3DHtvdX4Q1DpZ5frhN/qen4bOfLLVVfBZnzK7iTfmng9 uw1Ctn9lfuSgM/xlYAE2JM5CM5u+YSKRGQ0MJcqWAJi+wCM3whV+P6r4QOtCAhytxFjt 7LyUI1Ht8uk3j/Nqsbbv5rQXkbHHk79iAKk+356Jn18vw9TJnWl9EEFC5evAMZkauV8e GPRQ== 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=o/PB+AGUuNeNGH4XIGbb+K9nqQE5AjwWNwfZUx90U6Q=; b=kMUSJxIFmCeTtlMaA6sbUXSNCXDcqAMvWNmJkMCD+Hy81mDZHJkfRuyCEZfxqw81Vi GbY4iG5KomeoXv/CbGVd6wOQ4AUpltDprE2hOd2tPyZRbE3OxgYKehzAtAqHJ4eR+Scw zKi14nRANEA37uFNjVp7GZ4ctuqG1Yp+aGR1hqlTD/Il6YO2eH7PmXFyvXJWbvIrPGhE ZYx+G/APT9+ufAUD2DT/g5sPuM4/+ScOjIIajKwlQ1k/FjicY2RUyGLbXCJWpSPpFny7 XRVfJLbrv1urAJLDC29HHQhQqcE95X/qTvC+MtlXuqR5Cc8A6vuKpWlqTl0wrPq7DMgt n9tQ== 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 8-20020a370a08000000b0069f96278236si265027qkk.0.2022.05.06.00.37.34 for ; Fri, 06 May 2022 00:37:34 -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 07E1220D03 for ; Fri, 6 May 2022 16:37:33 +0900 (JST) Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by gw2.atmark-techno.com (Postfix) with ESMTPS id BA90A20D03 for ; Fri, 6 May 2022 16:37:32 +0900 (JST) Received: by mail-pj1-f69.google.com with SMTP id d12-20020a17090a628c00b001dcd2efca39so886366pjj.2 for ; Fri, 06 May 2022 00:37:32 -0700 (PDT) X-Received: by 2002:a17:90b:380f:b0:1dc:d54b:1888 with SMTP id mq15-20020a17090b380f00b001dcd54b1888mr2662174pjb.228.1651822651796; Fri, 06 May 2022 00:37:31 -0700 (PDT) X-Received: by 2002:a17:90b:380f:b0:1dc:d54b:1888 with SMTP id mq15-20020a17090b380f00b001dcd54b1888mr2662162pjb.228.1651822651520; Fri, 06 May 2022 00:37:31 -0700 (PDT) Received: from pc-0115 (162.198.187.35.bc.googleusercontent.com. [35.187.198.162]) by smtp.gmail.com with ESMTPSA id c12-20020a170902d48c00b0015e8d4eb2d6sm960174plg.288.2022.05.06.00.37.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 May 2022 00:37:31 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.95) (envelope-from ) id 1nmsWn-00EjJN-K0; Fri, 06 May 2022 16:37:29 +0900 From: Dominique Martinet To: swupdate@googlegroups.com, sbabic@denx.de Cc: Dominique Martinet Subject: [swupdate] [PATCH v2] network_ipc async_thread: fix hang on failed update Date: Fri, 6 May 2022 16:37:27 +0900 Message-Id: <20220506073727.3510746-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422235944.2808227-4-dominique.martinet@atmark-techno.com> References: <20220422235944.2808227-4-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 that will never finish. This can easily be reproduced with a large script that exits immediately with a failure code with swupdate -i or swupdate_client. Fixes: 626d83f8819d ("IPC: do not call exit") Signed-off-by: Dominique Martinet --- v1->v2: - taht -> that typo in commit message - fix leftover msg.data.status references Sorry for the mixup, I don't remember any other conflict when I rebased these so don't think there'll be any other problem like this but I'll double-check now and send another mail if required. ipc/network_ipc-if.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index c8a6cd02c72f..0f28dadcc137 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; @@ -37,14 +38,15 @@ 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 swupdate_result; + int swupdate_result = FAILURE; sigemptyset(&sigpipe_mask); sigaddset(&sigpipe_mask, SIGPIPE); if (pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask) == -1) { perror("pthread_sigmask"); - pthread_exit((void *)-1); + swupdate_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); + swupdate_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"); + swupdate_result = FAILURE; + goto out; } +out: + handle = 0; if (rq->end) rq->end((RECOVERY_STATUS)swupdate_result); - pthread_exit(NULL); + pthread_exit((void*)(intptr_t)(swupdate_result == SUCCESS)); } /*