From patchwork Thu Jul 14 14:47: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: 1656480 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=rzan5qRv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::338; helo=mail-wm1-x338.google.com; envelope-from=swupdate+bncbcxploxj6ikrb46yyclamgqejtnixda@googlegroups.com; receiver=) Received: from mail-wm1-x338.google.com (mail-wm1-x338.google.com [IPv6:2a00:1450:4864:20::338]) (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 4LkHQN2TF6z9s07 for ; Fri, 15 Jul 2022 00:47:22 +1000 (AEST) Received: by mail-wm1-x338.google.com with SMTP id k16-20020a7bc310000000b0038e6cf00439sf866160wmj.0 for ; Thu, 14 Jul 2022 07:47:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657810035; cv=pass; d=google.com; s=arc-20160816; b=CcNdk3Rz1CvFVammOHfApZMOoKY1hflZN2yv2orYOsgCij8eMaBfT8K9/o6yS5tepO yEzm25/Dz6HeugYbCdUaiNRDYCuyI3LRdGnEcPlAoicd8JwrkOG4+d1Qrsg+5OHiUGCB Ypx7K0wb1EVTxZsfGoRI8POUKhuzcmhZfiSn9B3jNqDCHujVcCWZ17OfcOGTJEQMWsUi xjI3Sj8VF2hNiMgf7S7/T6waqB+Rlj2b11OrmGvVwhJsR2yadUnEcqEPGljiZtqQgMUa fOVdL0vN4/EBrizc0k6jrETXQdl1XCjCfXu38qMrezOycpUiFWTDo8JmVt6bymZaU6/a dqwg== 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=k+3lm46ow6ohSuhctipIVdSCqBO4pbZ04BvdLXlXzvI=; b=C4BJQsJbUpC+wTVkymOyvk0hjVBjYFxK0N7JELadqfY1HjAJQnvzWeiOylWpn3ZjQ7 uCQhpB0cmiI1nq47305gCUYL0TO5vFq2v1K2ryZY12NSywQ9tvyeXrO0m5zdrUu4TrJ5 dY+gFB13j9eEc0qgx66OlJWCqGVjJ0hTrWPezVHelsqTwrgLb1FIhB/WVYJfdmR/85x/ SxXSn4/jaPSYionBTxZnAVOmZ6Ce49ugY3uK98pNB65iPSLO9gJQjd0Jen5wOaZSRuuR d1iZjAuwzADEEbRaojBj2Clz/DvVMUPiXBrW7yo8C3k2mhdPIteFeshLXsPpqDvZt/70 E1aQ== 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: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=k+3lm46ow6ohSuhctipIVdSCqBO4pbZ04BvdLXlXzvI=; b=rzan5qRvwTFf90l32EaILnLpVeXu7GoHpS10zkJp2SCftYfwvrYMbK4hVlG3wwxGmQ BMDVq/rsBw6x5fX+9sQ9gifV9jqSAftY+spe6Emo+UwOX7C2lyE+4Jr4K50Ux8E20OXw BhfNjYbpdHFO4ZrYc3NFKgkwHu1t4t5QasRgP7iaQDbpXdsOUOgpFHyHr84er/F43AuE OB7B9KrDuICYr/si8rsc35VhInXm3djz/B4S8hUYhQdGu3ocxVdQ8iF89uBuwLaycHW4 opEPI1+cQGD172tlnLTp+6GII6LezSC4Y7d98BmDEg1LmS0HdFwG4xEUcMEed14T1Tet Xyvw== 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=k+3lm46ow6ohSuhctipIVdSCqBO4pbZ04BvdLXlXzvI=; b=htqx9J1YjhLMSEKanAiaqsURozzthMpsB4HOOI/4kw8mkVW+/MxIuBG3MCo3OjNdoV MWQVUrvvaRmCx0iUZ9s7IXvpv7xOqPegQaLyQE5D7iXQXniwn9d3HYq7J2p1BEX4x4fI XRsryk4VCwZYOqKE/MqmaGNR1kTa25B1L2kTtRcZkP9m6zmw0xb4Ged8SmP+xxzY54x4 NQKbzs76J1Lc9E4G8lEBzc2ZfF4KYfRhaj2G7YyCzIPPEJJpyomqbNRINnZ4DAuCBQni zhierfsma52OiCXQ3BmDO6bxt5BbPRMulcivk2gIh6F/DkJzMYhTO9aCL2glXhMi1xUA G9vA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AJIora+x5DAcWo3isdg9NXstckImGFP+tfWl8hZkdEm2kCc8J17mot5j AWAz08jsrZKpt0MLwhZD4U0= X-Google-Smtp-Source: AGRyM1tZKEeRgjzZiG91D9Y54tRAS/T63YMQVM8P+96Y0ag5S7+KfxiOQFbNT/gQJtLfd2TupfUCdg== X-Received: by 2002:a05:6000:1567:b0:21d:abc4:29f9 with SMTP id 7-20020a056000156700b0021dabc429f9mr8427957wrz.181.1657810035617; Thu, 14 Jul 2022 07:47:15 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:1da7:b0:3a0:3b20:d119 with SMTP id p39-20020a05600c1da700b003a03b20d119ls21068074wms.1.canary-gmail; Thu, 14 Jul 2022 07:47:14 -0700 (PDT) X-Received: by 2002:a05:600c:1991:b0:3a1:9fc4:b67d with SMTP id t17-20020a05600c199100b003a19fc4b67dmr9487017wmq.49.1657810034585; Thu, 14 Jul 2022 07:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657810034; cv=none; d=google.com; s=arc-20160816; b=nptZyZK56cCNtrCOhYcZwh5wR74t7eootugwe17jqtIf1yv4nM3Wc7KRbsmNAp0DEM uAyIvEpRVoRPYSzjnH/lTxY2e+vRcaHpy3p0cDUee1mg6Z02IaDsEq9OpjPOD6qlgUS0 a2C+Vh0qFiqiic2R3504+Z0xoPZiasnRm2R1TQJNEQDBLnjtOnhajmJFpnizq+85wnyh UtkcUdclFgyINIMKEywloXHwd4BvmUOHXutOyN13HIOfpyAJBpp2tlhvCNIPcgc7TL7w i8p0x6PV88bCaKCCYmxH0zlUim2992nOiAiCHKTFvBygyuvOC+pGh9hf+xvue03KYj/z Ip5w== 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=+U0lhDRpM53K2AIidl4LBH/HKbW4lnxuxk0J8zTwN4w=; b=Jj6Egx3ON3AnL4Zv52/KvjCr85xwE1kRMDjDAyOi8Mf+W2IHU3qti4JEOetcuH62AZ 1YlsBqgGgMAUgdrXzTTbTJqKVLHk7UkuA05Fp4SFHY2WxRUL1Fg17UWNV8PaLnf+ceyM IxZtdBqI63PjFiZTN+Yeuyz2C2Dwn+ZXuXuB48cfJa8D43gwQxIz3/8e7nYW5lvf2Klu ouReo64yNrasU4++OPGHHEKNXM98HflIa9mH4uXR5zzpnSKEkegd6u03f3PwX7cj7RZp wtusDQ+X25wVMxUndMHhdAIsVfBY7bSjhfOKIk7+xGIK7gsDfAReUfmwXedOZbFxqD5s xTAw== 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 bz9-20020a056000090900b0021da74303d2si70977wrb.8.2022.07.14.07.47.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2022 07:47:14 -0700 (PDT) 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 4LkHQB2QByz1r1fj; Thu, 14 Jul 2022 16:47:14 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4LkHQB28fpz1qqkd; Thu, 14 Jul 2022 16:47:14 +0200 (CEST) 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 DSsAog8IHkKh; Thu, 14 Jul 2022 16:47:13 +0200 (CEST) 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; Thu, 14 Jul 2022 16:47:12 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 7A4584540B53; Thu, 14 Jul 2022 16:47:12 +0200 (CEST) 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 eyYyYJ4Horc1; Thu, 14 Jul 2022 16:47:09 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id C416F45405F7; Thu, 14 Jul 2022 16:47:09 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Marco Braga Subject: [swupdate] [PATCH] Do not call sd_listen_fds() on cleanup Date: Thu, 14 Jul 2022 16:47:06 +0200 Message-Id: <20220714144706.2449544-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: 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: , systemd creates the Unix Domain Sockets just once, but duplicates the fds each time the daemon is started. According to systemd descritpion, sd_listen_fds() returns the number of passed file descriptors when it is called for the first time, successive calls return 0. It is then wrong to call again sd_listen_fds() to decide if the socket must be removed, because this call will always return 0 and will constraint SWUpdate to remove the sockets. The effect is that a "systemctl restart swupdate" will lead to a not working SWUpdate, because systemd will still pass the file descriptors, but the socket files were removed by previous run. Signed-off-by: Stefano Babic Reported-by: Marco Braga --- core/network_thread.c | 2 +- core/progress_thread.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index 0e03188..61de5e0 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -313,7 +313,7 @@ static void empty_pipe(int fd) static void unlink_socket(void) { #ifdef CONFIG_SYSTEMD - if (sd_booted() && sd_listen_fds(0) > 0) { + if (sd_booted()) { /* * There were socket fds handed-over by systemd, * so don't delete the socket file. diff --git a/core/progress_thread.c b/core/progress_thread.c index 7e21b3f..0d797cd 100644 --- a/core/progress_thread.c +++ b/core/progress_thread.c @@ -225,7 +225,7 @@ void swupdate_progress_done(const char *info) static void unlink_socket(void) { #ifdef CONFIG_SYSTEMD - if (sd_booted() && sd_listen_fds(0) > 0) { + if (sd_booted()) { /* * There were socket fds handed-over by systemd, * so don't delete the socket file.