From patchwork Thu Mar 21 05:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique MARTINET X-Patchwork-Id: 1914303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=ehJhwKEX; dkim-atps=neutral Authentication-Results: legolas.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+bncbcwivbv7sugrbqu556xqmgqe5pqs74a@googlegroups.com; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0Zkv571pz1yWp for ; Thu, 21 Mar 2024 17:08:05 +1100 (AEDT) Received: by mail-qt1-x83c.google.com with SMTP id d75a77b69052e-42f521e0680sf5556741cf.1 for ; Wed, 20 Mar 2024 23:08:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711001283; cv=pass; d=google.com; s=arc-20160816; b=VSCYs5dEU4XXFNfq77CdCyaTJVaWUkneGfH9rZvrYDiCv1KBwa4+F9y9f8/qCj3PQo S0niLL11o4T6Mss6A4oSuelX1WyyfsyC9bN/d7D5ppPYc3XnWKzrOVXoKaqciNBVUn5j GtcDS6RqM3pYYJ4KoDQsSNrl6xBPCD4g9mPpFlEDDC8eLL8f9I533XwkiZyAknxeVpsZ xwzBL29LApGSMp2bcA4dUX1W0udTLcGpl5u8Rna5qJcBPkRHvFjdzKVXn7C020UVxS8n qWVU82DP34cLMxBUrQhuTvdRciuaBwuA5Yl5De7I8p7llQ/SSbE4fZrHcUvMh43+jVJ8 ExoA== 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=6jLzs68Cm4HHx3Fp7huWfhaZul7p8BlwdRt7+lL925E=; fh=syPPtf0umg2159W9oY0fq9M9NAhDuYZF0TJAq0GCJcM=; b=YmS+ppihtffcun1pVBffg+lcuZ//wszBGvrhyeUnE4jJcNUtd2DxTmj5NcLrrSAqtC 3XQSCyCnaNOkayez8p4DQym8VEY7GYIwEf3h7ps4lI/TQ0/vfdK7jjuzk4qddJet2TD7 9AsUvSsv5+Dy4LRQiLPttqoYB1utYBghKtZUWHleUBtNtJbIL4hCSozCYYXKZozpgk4O g3aYKj6WjfGmArFl+cFsLpeaHCVob7jlO1EdazjaeksJGtI309Z7yvJEXzMCkdtYA7Xe khanBbbnoKX/psAlR6vzI6zj4EIaGUhMxk8t/AJWlrU5vmyMDE7M/XDxZdNdrUw9XAwK /XvA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=hXnO0plc; dkim=pass header.i=@atmark-techno.com header.s=google header.b=IYLjfEGa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1711001283; x=1711606083; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=6jLzs68Cm4HHx3Fp7huWfhaZul7p8BlwdRt7+lL925E=; b=ehJhwKEXUCqOhHl1td/9ouWlqus44bRFw/w3z3fS0rrB6tKSHQ5SwkzStMtrOTGCTP nH/IUe5B9rQGWFh0+2ThJ6V5ZHbew/jIyD+WDfX3eDm62b8YkKFZZ6Oncf9sWogMswrV 0xp033GMReg+fp2NJPZpxcU9BILwFKMgXgjTbm+lLKAKcWKz3ORaPUGN0RM+8re3s8oU 0J4/3hfJpXonPHc0kQOGSmj6lwtxVWT63+dm7oqpBWgbgBvIICwqSOfF5JJ2k/yeP9W2 5GCsPpedeO+YLrMXXsl/hRKbk96geVta7fj94R7DL8gXkL+5dCj8BXwGhzKByRwoKN0C HpLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711001283; x=1711606083; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=6jLzs68Cm4HHx3Fp7huWfhaZul7p8BlwdRt7+lL925E=; b=HE8pwKp2pse8DGxHDfhuiQhZu8qkG0hJMLWm49iwtcyQtpyEaE1Bi/oFaTuaqrsE1E 0PJX0f+yPN358ApNcvB1Bi/d2Nf5jd0WSAxOvq0j0m7KWbnsTyrNaqhHK8NH0IZ2pFpF XQoLW13mnfQcIv+Cb3lv0yCjNyTUkdlJVdcZ7uDIvWTMU84Gb2B+rfjv8AUvTsTTdm8/ rvZWb1mRRg/aIfm4rcCVonyWVA8ife6y15MBhK8EYGbAcH23l8RuENja27eFbgCGS8f9 /hMGXh3r0hSduC3IiDw0lFfsuEZ6qK93SwznsujvbjwXIsw1XY5hWFrYfdP2rbIlKW0S P2hQ== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUSB2ro5Uma90IJM40AW+YNt7gdh7ZrXLxRILzZOKNrcsIV05B298cql5YlQ+2IwdSpLnfEHAT+8DnOLeu1Q8SJWLEj2OfZ5nJxnFF5IA== X-Gm-Message-State: AOJu0YzRqhpCnomugXw2aw4VcVT18f3oTS7uClHXir5K1/dUSJNyxhLZ FAg+TRy6LaKkmA0PKGntVi/LwymZMLcSAddpNTH8jTETvO6sR+uL X-Google-Smtp-Source: AGHT+IHq3vpLbQCfUaZEoiBtEXQdbHpKv9cnFZeTrYDvcqG26YOG6gZGCU0zsN1XaqcWJPs0aZhpww== X-Received: by 2002:a05:622a:138f:b0:430:c37a:3649 with SMTP id o15-20020a05622a138f00b00430c37a3649mr4354916qtk.52.1711001283235; Wed, 20 Mar 2024 23:08:03 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:ac8:570a:0:b0:430:ef0a:a35c with SMTP id 10-20020ac8570a000000b00430ef0aa35cls765830qtw.1.-pod-prod-07-us; Wed, 20 Mar 2024 23:08:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWlpiqa//2J4QA+O3hIAz947xb+Rlzw+whhPEcRveLgwjWafnhtass813Be6VRL1qwffOM/xt8ucrWNQ4+dFOMNMGDhL0codYbO X-Received: by 2002:ac8:5851:0:b0:430:d73a:d3b8 with SMTP id h17-20020ac85851000000b00430d73ad3b8mr3837050qth.54.1711001282217; Wed, 20 Mar 2024 23:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711001282; cv=none; d=google.com; s=arc-20160816; b=JwPrEasfzuPdc++K4lsTnxoMM2MnkIBbGTw2o/N8X6cJzpKVPuKW8qsOehOI1kzmZY oWHXY9GrE29pncB5P1+cfD3eDmMQCW4cxn0RpfBrQdPx5L0qjWdVtcDFr2gtxSUmqTdm tiOAS6m9HhS/qd+UtkAqqhvzKaV4rff/EOpEH9DlC5rAw9cqns7r+INEpPxXG8FYUQQY sZM9VzCYbh5AbGwuh5/02MiIZzYn9RqYHmEVyEygeMdklQzBQSI7B77rVtRAXSpSQ2/f Y9r/IMZBCBGcx7uHRfs/WyLKcyM8sWGeVdyLu7MN0iqsigbNx2rd4aJBy7Uknm2M0s1X k65w== 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:dkim-signature:dkim-signature; bh=r6si6ATczV/RPSqk00JKUdv4vbFVSWxYh8JLyBgxln0=; fh=Lnyo7ZFziOoj0hegQUeRrMMc4uQLUTE/Ow60I4gl4o8=; b=uIa//GIm20CyvouYdjlVlmAxBRqzTDvHcdDfJcm16rxQ5DuhJYKJQ9qP1ngunr11mK UCi+2MaCuwbNseJ0OVRq6eb33YLKkorttxRgNQQfb3xX9mhPZbBQzfUe1gRimc2bnnlp O92M2V/1I3gO2uA507Qx0OAN9rfZIH5kRXIAZKDFI+i8owgBZ6gDqQHB9RiHwY4GNEx3 wq2CFO+Jr2f7UEjPalCMj1zHLVXOQgnrpkIHxEt4jRAYnmLPBrkjljryYIzZPZtijEsd yd/zPXQmwZNaWGcmneNad3c6VCkcWUuJYJrdgnDF4bPC2HOYYpZFp36Z/EqhrsPottJw uZWg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=hXnO0plc; dkim=pass header.i=@atmark-techno.com header.s=google header.b=IYLjfEGa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTPS id k7-20020ac85fc7000000b00431257474fdsi16314qta.5.2024.03.20.23.08.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 23:08:02 -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 C02B32B0 for ; Thu, 21 Mar 2024 15:07:59 +0900 (JST) Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by gw2.atmark-techno.com (Postfix) with ESMTPS id A16142B0 for ; Thu, 21 Mar 2024 15:07:59 +0900 (JST) Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-59fb2af0267so514562eaf.1 for ; Wed, 20 Mar 2024 23:07:59 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXxvoOn7co3BUJk/aY7A/2R99sHUUUsNw8neUC6kMujPyw91YMZ2ZpAWcgiivPILwOKO/Qwz7d+LX/HPiLaIL5kB4RpjDR6EeDK X-Received: by 2002:a05:6a20:651c:b0:1a3:6704:8885 with SMTP id n28-20020a056a20651c00b001a367048885mr3538633pzg.51.1710999718800; Wed, 20 Mar 2024 22:41:58 -0700 (PDT) X-Received: by 2002:a05:6a20:651c:b0:1a3:6704:8885 with SMTP id n28-20020a056a20651c00b001a367048885mr3538619pzg.51.1710999718321; Wed, 20 Mar 2024 22:41:58 -0700 (PDT) Received: from pc-0182.atmarktech (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id r4-20020aa78b84000000b006e5f754646csm12535141pfd.139.2024.03.20.22.41.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2024 22:41:57 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1rnBBd-009fBM-3B; Thu, 21 Mar 2024 14:41:56 +0900 From: Dominique Martinet To: stefano.babic@swupdate.org, swupdate@googlegroups.com Cc: shiita.ishigaki@atmark-techno.com, Dominique Martinet Subject: [swupdate] [PATCH 1/2] network_thread: block SIGPIPE in network thread Date: Thu, 21 Mar 2024 14:41:45 +0900 Message-Id: <20240321054146.2303245-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=hXnO0plc; dkim=pass header.i=@atmark-techno.com header.s=google header.b=IYLjfEGa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , From: Shiita ISHIGAKI SIGPIPE was blocked in the subprocess thread since commit a781be1d0b7a ("network_thread: Don't SIGPIPE-die on IPC client crash"), but the main thread sometimes sends reply through write() directly (for e.g. STATUS) In this case, swupdate crashes if the client is gone, which is not something we want. Since we block SIGPIPE before creating the subprocess thread we no longer need to block it there. (Add errno in write error message while we are here) Signed-off-by: Shiita ISHIGAKI Signed-off-by: Dominique Martinet Acked-by: Stefano Babic --- We had a weird swupdate failure in "hawkbit mode" that turned out to be two different problems, this appears to fix the issue and I checked SIGPIPE is still blocked in the subprocess_thread but please double-check. core/network_thread.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index ca23908d0cda..d7b713fb2154 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -337,11 +337,6 @@ static void *subprocess_thread (void *data) (void)data; thread_ready(); - sigset_t sigpipe_mask; - sigemptyset(&sigpipe_mask); - sigaddset(&sigpipe_mask, SIGPIPE); - pthread_sigmask(SIG_BLOCK, &sigpipe_mask, NULL); - pthread_mutex_lock(&subprocess_msg_lock); while(1) { @@ -393,6 +388,11 @@ void *network_thread (void *data) SIMPLEQ_INIT(&subprocess_messages); register_notifier(network_notifier); + sigset_t sigpipe_mask; + sigemptyset(&sigpipe_mask); + sigaddset(&sigpipe_mask, SIGPIPE); + pthread_sigmask(SIG_BLOCK, &sigpipe_mask, NULL); + subprocess_ipc_handler_thread_id = start_thread(subprocess_thread, NULL); /* Initialize and bind to UDS */ @@ -644,7 +644,7 @@ void *network_thread (void *data) if (msg.type == ACK || msg.type == NACK) { ret = write(ctrlconnfd, &msg, sizeof(msg)); if (ret < 0) - ERROR("Error write on socket ctrl"); + ERROR("Error write on socket ctrl: %s", strerror(errno)); if (should_close_socket == true) close(ctrlconnfd);