From patchwork Mon Feb 27 09:08:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alin_N=C4=83stac?= X-Patchwork-Id: 732735 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vWwqs2wLpz9s8X for ; Mon, 27 Feb 2017 20:08:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="clMia61o"; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 7EA78B90FA1; Mon, 27 Feb 2017 10:08:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Mon, 27 Feb 2017 10:08:43 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 25DE0B90E2E for ; Mon, 27 Feb 2017 10:08:42 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .gmail. - helo: .mail-wr0-f195.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 27 Feb 2017 10:08:40 +0100 (CET) Received: by mail-wr0-f195.google.com with SMTP id l37so673481wrc.3 for ; Mon, 27 Feb 2017 01:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=syN0R2HDav5CKZ+PivUOvFspg1EmwFtbi9d47rFbt/Q=; b=clMia61ob7BjySa81rcXNOhPnYPkM4EDM0lMxE6ZWt4oJ9C//e8P/ePUmlWC3k9WMM fapY6ogR8hrQgFM5gYP9n2rpzKpRcOMsHjFZoPikeAMw08YbDM5LvU2paRWz91iiLVXT 786KXb6U3K0Lm5ZV4fKg19/j9hLsZD/6yCQ9pkUkM2mhUdbvu1LGMVlGFPovMcVKKyhF /CtiGKhBsfeNwi870WoE4PsfDNm1TFPXKQhbKmfohDmz6JKi5NAd+08isdcz1WRlupA0 CfzcNJiRgPtGVuAf2Q6Dn3WbVeoul4gjwNEbkF6B0dcsU8zR1oM+Q7ZLkoGWCeyXKB7v 5Emg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=syN0R2HDav5CKZ+PivUOvFspg1EmwFtbi9d47rFbt/Q=; b=TnmryhFoNh86uL2zdBQ0SR8CcHSaXya0i7fNyszhNG5ex90iK4U4S1uE2WOCT7O9fo xYSBxhUCYi8iqgit+gRMIT657swZH4HdP41CY64qwR3QLPE1s9D5C05lWgV5p2OFMi44 JJsqtG5NT+JDdefR3WXbG9SghhcWX7+czMlUomNRBVl6AfPyYVbmuhvwUmfQ/vZ//aAR x5ghQ9dNKdOwit1T5VCUd15U7tXzNaYnuoypoWVM6YCWA5Gv1xxg7iCiEJK8Z2b8ZduE m0h9Q+mYI2ceMxa2HDTyO89BEmtky0YJgR9PA+/RlRCrP6oMpXUD8kVu5aZ8bUpvlh/7 fC3A== X-Gm-Message-State: AMke39mohbmt/RDhG5LyPhR3YrEYfXHhjPZoM3wfjK3eECm373NCFJRHvAwolwaHXb1CoA== X-Received: by 10.223.174.26 with SMTP id x26mr13833698wrc.124.1488186519422; Mon, 27 Feb 2017 01:08:39 -0800 (PST) Received: from cplx250.edegem.eu.thmulti.com (14.125.146.82.ipv4.evonet.be. [82.146.125.14]) by smtp.gmail.com with ESMTPSA id o70sm13370413wmi.26.2017.02.27.01.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Feb 2017 01:08:38 -0800 (PST) From: Alin Nastac To: John Crispin , openwrt-devel@lists.openwrt.org, lede-dev@lists.infradead.org Date: Mon, 27 Feb 2017 10:08:34 +0100 Message-Id: <1488186514-5988-1-git-send-email-alin.nastac@gmail.com> X-Mailer: git-send-email 1.7.12.4 Subject: [OpenWrt-Devel] [PATCH] procd: service gets deleted when its last instance is freed X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" This fixes the following regression introduced in commit 961dc692aff7457f874bce61f8e766514edcf794: 1) reboot using the following configuration root@OpenWrt:~# uci show system.ntp system.ntp=timeserver system.ntp.enable_server='0' system.ntp.use_dhcp='1' system.ntp.dhcp_interface='wan' root@OpenWrt:~# uci show network.wan network.wan=interface network.wan.proto='dhcp' network.wan.ifname='eth4' network.wan.reqopts='1 3 6 15 33 42 51 121 249' 2) if obtained DHCP lease has an option 42 sysntpd service will have an instance 3) run "ifup wan" 4) although the same DHCP lease was obtained, sysntpd would be stopped Because sysntpd service is deleted when last instance is freed, its triggers will also be released. Without these triggers in place, sysntpd will not be reloaded when a new DHCP lease containing option 42 will be received. Signed-off-by: Alin Nastac --- service/service.c | 5 ++++- service/service.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/service/service.c b/service/service.c index 0584ee0..9675ba2 100644 --- a/service/service.c +++ b/service/service.c @@ -140,6 +140,8 @@ service_update(struct service *s, struct blob_attr **tb, bool add) vlist_flush(&s->instances); } + s->deleted = false; + rc(s->name, "running"); return 0; @@ -149,6 +151,7 @@ static void service_delete(struct service *s) { vlist_flush_all(&s->instances); + s->deleted = true; service_stopped(s); } @@ -602,7 +605,7 @@ service_start_early(char *name, char *cmdline) void service_stopped(struct service *s) { - if (avl_is_empty(&s->instances.avl)) { + if (s->deleted && avl_is_empty(&s->instances.avl)) { service_event("service.stop", s->name, NULL); avl_delete(&services, &s->avl); trigger_del(s); diff --git a/service/service.h b/service/service.h index d4f0a83..cc629b1 100644 --- a/service/service.h +++ b/service/service.h @@ -40,6 +40,7 @@ struct validate { struct service { struct avl_node avl; const char *name; + bool deleted; struct blob_attr *trigger; struct vlist_tree instances;