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); From patchwork Thu Mar 21 05:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique MARTINET X-Patchwork-Id: 1914300 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=UuGPiHvq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::f38; helo=mail-qv1-xf38.google.com; envelope-from=swupdate+bncbcwivbv7sugrbmmu56xqmgqeixbtzfi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-qv1-xf38.google.com (mail-qv1-xf38.google.com [IPv6:2607:f8b0:4864:20::f38]) (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 4V0ZJR5p4Nz1yWs for ; Thu, 21 Mar 2024 16:48:38 +1100 (AEDT) Received: by mail-qv1-xf38.google.com with SMTP id 6a1803df08f44-69046d68828sf7377866d6.2 for ; Wed, 20 Mar 2024 22:48:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711000113; cv=pass; d=google.com; s=arc-20160816; b=cT2noZLOOnndIiNiQ+XAU9f714puEmqcv9ScTmxia+i3lb53iyoqPF4qew8mBF2CoR HIOceUcWwTUjG6PVPD0iBpQ3eDSqzyvM2PVO85zTo5bOUkgdV8TzK6byCWk2lBO4VDCe oLUWbWQpfKdXW5k7LnFRsR/9zyNTDXeo2Db9qzmQxeclvqfuFhN9q9g29Rgnasj2LLuS KGHAF6piZLQ/2SVDSJzdKVdxhUWCXJih9O+LiUpAF0l3jbDWZEnZ0dM/t8hGllvCBWu8 DvyLBcn6V/DxPM1/INBaDpMf8jHetb165OnwT5Zgih1pmo3o1J4YFPEod0g9DFs5LMxm X2tA== 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=xxJxbfgqWVYomi6eScPPgaic8CcwAnh0Q6xJFvwQazQ=; fh=+MttpEaHU7ZbDqes7xCnQTNWMpC4/63U7DVmO1hJsAQ=; b=kDP5hh7YmIwQcecAbCewlMSIoPIkSdIwT+XXnoHrBNHw9gvFmP63YXLoG0WCocfDwG xmMqY7vtvxwVG/HleviQZPf+U6hISbYk/GceEMYqJoVarCweed1ifETGaJONCpC/f8GC H25d5ByeJC5ZSkn4cf/UXa7o46mVn4EZaHcbBwyV1FDv1vyfVDhWMG/o6La/hF1h1nPz sCoMju/PQe2zlcwS6HtF6y6xwi1X9Yazu2Nsll8pzPM7u1HNMhrdSwR1djeQduBIYpyL jv02r2H4yXSmaqz7djGSQkMBqE7mH9WOEWfBNX53vs2l/N7Zf2JACjiq0HZiPIIwl1fb QN1Q==; 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=DsZoGfNW; dkim=pass header.i=@atmark-techno.com header.s=google header.b=h11KTpwE; 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=1711000113; x=1711604913; 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:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=xxJxbfgqWVYomi6eScPPgaic8CcwAnh0Q6xJFvwQazQ=; b=UuGPiHvqKZVMnSMjxR7LKeARfOBwJYauSoucEB0kWyR0MNje9XlJURbHsxIEbE3D0j M9MYGWYK133CfXl0/rqoreGB7naBySZy1dbpzkftrVaBbvXEUSI8yP5O+SVNd7mMyw4r Wmz5CdnO1Any9q9LUfEJ3KkOSFbQKgdJ5NcKOLir72ZHosZLu2m+Wn73bjikoYdm6+xs wJv/fzQg6rCVfoUXxEWEl1aIgIrsm/pmMtr5ksvrzT2VK5ARHRKEdKzFF1D/O4wHILIR Cb+9RjCKziFN2VjnXS1JeQ4a41gdpZqvi/Y1Be5M4vL9e1LY4GEeboxCFtabgNo+7aoO 1PHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711000113; x=1711604913; 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 :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=xxJxbfgqWVYomi6eScPPgaic8CcwAnh0Q6xJFvwQazQ=; b=S0Cr0JqH2RkLWB/WUoga2GbbN33ODpmzasVKHjjQQGAEdyZ2W+yXJ1ZZXJjZUt6YdB mVwKtUCCBjWqPEIV44exhP8oLAwiOBSS69DKN3mrlhMJMbClAHpYE/0qVYfASBK3F4nv YfFUxIxWdwKD1kY2FzdSx0yyJWf9xKm2kTEwo1fGZytcVLuWmthYHvm/1m4P9kYsaepp acPwR15Gf+30YNcxbvn8zQ0K2f3oSOCOva5N4ZRSMQXjRJp7kTEY+LgIrrIe/JjsbfkE QPRO+gwl34aMiXX6Rh4+5p4LCMlwiElB19+f2+S+DYLQETHJY+8pSNK5dG+xp0n8i/ea W4QA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCXSTOZSBtNcwoEPxjMxYepPaB4fZdsHSumgPQP1ND+Y+e1LHmkdtipS2RUhjJMJvGi9Z1+ZiSEs0uzXj5mtgDY+lh9GWONyX69FPc+emA== X-Gm-Message-State: AOJu0Yw8ULBDWqvbrfpLRoyedcr6dzNzXtxXrvihA0IlXFSuHffweCDV oJn3i6dSs6KHkYZrv5Wu1UQr6YP7Um8YyTdzkUdCmCgzqbXrliiM X-Google-Smtp-Source: AGHT+IEDEceaU5KnX1s6BMFvdRX3uzhlSnJTnZCFIMFOa1SuBRCsqYGJ47sl+UKbQ3t0RDzziukvDw== X-Received: by 2002:a05:6214:401:b0:68f:2b35:5edf with SMTP id z1-20020a056214040100b0068f2b355edfmr1052691qvx.13.1711000113585; Wed, 20 Mar 2024 22:48:33 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6214:250c:b0:68f:c7e6:37e3 with SMTP id gf12-20020a056214250c00b0068fc7e637e3ls898199qvb.1.-pod-prod-04-us; Wed, 20 Mar 2024 22:48:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1OJvd5eja99z+GjoCVElp1pLnHRRUgPMHiWrjBoKjTnB0po5cRvyMQ+XDIPlHpJuofvyaoWaXjZKHmqG6dNkS+lr5jDWcnabV X-Received: by 2002:a1f:f4cd:0:b0:4d3:cff6:79dd with SMTP id s196-20020a1ff4cd000000b004d3cff679ddmr885502vkh.12.1711000112229; Wed, 20 Mar 2024 22:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711000112; cv=none; d=google.com; s=arc-20160816; b=HWCnqNC3gEoMtc30KjCRH+YII/L/oBUULezX06M+G6ry5n1xYOVPOrIpDBw+OEB+Yl 6CK8/t8n7rHDNmy+QsT25txXkmK75mpuh93HJL/fngQMdJ2VnUpsVx0jrA5JWwQBXyqF CfuDG+Xt8swbiHZxbGYK1wi5FOIoK8xS5Vr6OzOACgzqQv6Z6z7k7XoAxuIwYdkByjnX +ezVv4+y12V54nfkI2SG9+Qj/ExToB393dgXakVTmpMQdmgdwHHnEUSCwC1XPCdOADHn Ws+dcsSAO73aVnQ5KxKV9Pe8m0T8wCkdrm+Z/BxruRRRoumuDg14++A5Ez27UjCmdIrq WE0g== 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:dkim-signature:dkim-signature; bh=0DUlRs6A8LrnvJE17jF+TwAUmol52pCKAoQ/hRMs0hc=; fh=hkVwg08vVHVRtXWCtqUrzil0kKIQfRS9xgbDVkAVEMI=; b=LU5vnZ9DSihDw0Ttx0heP1WpPd2grRYoxyd259e/zCCExXJwhZ0d77533r6Hz6p5y0 AHZpQLAVFq7fHleXCq7wwE/G3biyxZz4a82oHlVD/p0C94dLPwtk0qYMrgNcAODiR/5Y 6WO/XAs/0aWzCpniaUurfSEdsXivJ47LzIUjWjMCcdtttJQXhBvZbOi/kuTZ99+Z9m/z zPHeU00v1tqW56cjPTl/XZ3ANfbjGlrDG2HztekSVU++XE0oyDqZrnbbhovT0epPgCbV fH8OryvDxsigAqPHw6o8Xh3DXi1t3cd/m3RwLz5BItz85LGguaG4LutF8T8JiiVGqMou U0tA==; 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=DsZoGfNW; dkim=pass header.i=@atmark-techno.com header.s=google header.b=h11KTpwE; 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 r12-20020a0ce28c000000b00690d0cb25a1si1271374qvl.8.2024.03.20.22.48.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 22:48:32 -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 B00A12B0 for ; Thu, 21 Mar 2024 14:48:29 +0900 (JST) Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 93C942B0 for ; Thu, 21 Mar 2024 14:48:29 +0900 (JST) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-1dddb2b6892so4495085ad.0 for ; Wed, 20 Mar 2024 22:48:29 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVZZ7WJBXvEPX8DU+vo5Vsi6Pyqt/LUS9oL2p3dvwDOqeTlsRZ1YrxleMPJNHefffsnTSMmjUrZu8sb+oMzZ4hLzI6kWPXtuE4G X-Received: by 2002:a05:6a21:788d:b0:1a3:3089:9de5 with SMTP id bf13-20020a056a21788d00b001a330899de5mr1286925pzc.0.1710999719090; Wed, 20 Mar 2024 22:41:59 -0700 (PDT) X-Received: by 2002:a05:6a21:788d:b0:1a3:3089:9de5 with SMTP id bf13-20020a056a21788d00b001a330899de5mr1286920pzc.0.1710999718760; Wed, 20 Mar 2024 22:41:58 -0700 (PDT) Received: from pc-0182.atmarktech (162.198.187.35.bc.googleusercontent.com. [35.187.198.162]) by smtp.gmail.com with ESMTPSA id d9-20020a170902654900b001dd0d0d26a4sm15083216pln.147.2024.03.20.22.41.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2024 22:41:58 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1rnBBe-009fBM-1O; 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 2/2] suricatta process notification: improve ipc_get_status scheduling Date: Thu, 21 Mar 2024 14:41:46 +0900 Message-Id: <20240321054146.2303245-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240321054146.2303245-1-dominique.martinet@atmark-techno.com> References: <20240321054146.2303245-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; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=DsZoGfNW; dkim=pass header.i=@atmark-techno.com header.s=google header.b=h11KTpwE; 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: , The process notification thread gets messages from swupdate to submit them to the hawkbit server. Before this patch, ipc_get_status_timeout() was called in a tight loop, probably with the assumption that it would wait until the timeout happens if no message was available. Unfortunately, the server just replies immediately that there is no message, so this would just hammer the server in a tight loop. Furthermore, on slow devices if the server takes more than 100ms to reply we close our socket so the server would crash to sigpipe without the previous fix. Adjust this loop to: - since ipc_get_status() always returns immediately the timeout is useless, use the version without timeout. - wait 100ms before calling ipc_get_status() again if no message was available. Signed-off-by: Dominique Martinet Acked-by: Stefano Babic --- suricatta/server_hawkbit.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 1633c5cca65b..7ceb1dc038fd 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -997,7 +997,7 @@ static void *process_notification_thread(void *data) for (;;) { ipc_message msg; bool data_avail = false; - int ret = ipc_get_status_timeout(&msg, 100); + int ret = ipc_get_status(&msg); data_avail = ret > 0 && (strlen(msg.data.status.desc) != 0); @@ -1060,6 +1060,10 @@ static void *process_notification_thread(void *data) if (stop && !data_avail) break; + + // wait a bit for next message... + if (!data_avail) + usleep(100000); } pthread_mutex_unlock(¬ifylock);