From patchwork Fri Sep 18 07:59:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 519163 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 6180C140273 for ; Fri, 18 Sep 2015 17:59:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b=voo94tfj; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id BBE3B2807DB; Fri, 18 Sep 2015 09:58:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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 version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id D4E9E280745 for ; Fri, 18 Sep 2015 09:58:29 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 18 Sep 2015 09:58:29 +0200 (CEST) Received: by wicfx3 with SMTP id fx3so20172167wic.0 for ; Fri, 18 Sep 2015 00:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=DOISfcAn72dH9CcrI6ikeo6t4Jsi4yUYIwuiLY2q8Eo=; b=voo94tfj55l0bDF4tHM6A3OsAh5PacMkJH+64IEvNfjU9QtbMkk1b6yQGf/zL0gqht BuYRIGEDEprSjBDSN9I2dhtSb2X3aSXkihyh2rLEy3RDvyv0syKUKgbzO77seInNcLGO afWYUGbPePgaX8/2VeD/L+vJHRw4XBMnMSWSywp6QCLQfjW65JM92ptYONiKWGqV6T02 be9+lUtk1lrzuPUy73W9/hRVB9/oVXehepGkdPqdkPvBNP0Wwvd8oDd5+fTXg6TjVIiO rF7csQJJqkSy6e0AN4hisgKvKd8thLW/IkFVx2aSX/VmPhVmQq8ow4LwkiWCVRBmBf5j QyuQ== X-Received: by 10.180.96.164 with SMTP id dt4mr38193782wib.53.1442563181126; Fri, 18 Sep 2015 00:59:41 -0700 (PDT) Received: from hschaa-desktop.site (HSI-KBW-217-008-059-040.hsi.kabelbw.de. [217.8.59.40]) by smtp.gmail.com with ESMTPSA id mx19sm14137217wic.0.2015.09.18.00.59.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 00:59:40 -0700 (PDT) From: Helmut Schaa To: openwrt-devel@lists.openwrt.org Date: Fri, 18 Sep 2015 09:59:13 +0200 Message-Id: <1442563153-680-1-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.8.4.5 Subject: [OpenWrt-Devel] [PATCH] procd: Allow override of default respawn parameters X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 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" Allow to pass RESPAWN_THESHOLD_DEFAULT, DRESPAWN_TIMEOUT_DEFAULT and RESPAWN_RETRY_DEFAULT as parameters to cmake to change the default respawn behavior. This can be used to set the default respawn mode to infinite retries for example. Signed-off-by: Helmut Schaa --- CMakeLists.txt | 12 ++++++++++++ service/instance.c | 4 +++- service/instance.h | 12 +++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6af17a3..721a381 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,18 @@ SET(SOURCES procd.c signal.c watchdog.c state.c inittab.c rcS.c ubus.c system.c SET(LIBS ubox ubus json-c blobmsg_json json_script) +IF(RESPAWN_THESHOLD_DEFAULT) + ADD_DEFINITIONS(-DRESPAWN_THESHOLD_DEFAULT=${RESPAWN_THESHOLD_DEFAULT}) +ENDIF() + +IF(RESPAWN_TIMEOUT_DEFAULT) + ADD_DEFINITIONS(-DRESPAWN_TIMEOUT_DEFAULT=${RESPAWN_TIMEOUT_DEFAULT}) +ENDIF() + +IF(RESPAWN_RETRY_DEFAULT) + ADD_DEFINITIONS(-DRESPAWN_RETRY_DEFAULT=${RESPAWN_RETRY_DEFAULT}) +ENDIF() + IF(DEBUG) ADD_DEFINITIONS(-DDEBUG -g3) ENDIF() diff --git a/service/instance.c b/service/instance.c index 40ff021..9d4df7c 100644 --- a/service/instance.c +++ b/service/instance.c @@ -709,7 +709,9 @@ instance_config_parse(struct service_instance *in) if (tb[INSTANCE_ATTR_RESPAWN]) { int i = 0; - uint32_t vals[3] = { 3600, 5, 5}; + uint32_t vals[3] = { RESPAWN_THRESHOLD_DEFAULT, + RESPAWN_TIMEOUT_DEFAULT, + RESPAWN_RETRY_DEFAULT }; blobmsg_for_each_attr(cur2, tb[INSTANCE_ATTR_RESPAWN], rem) { if ((i >= 3) && (blobmsg_type(cur2) == BLOBMSG_TYPE_STRING)) diff --git a/service/instance.h b/service/instance.h index 3fb33e9..ab05f20 100644 --- a/service/instance.h +++ b/service/instance.h @@ -20,7 +20,17 @@ #include #include "../utils/utils.h" -#define RESPAWN_ERROR (5 * 60) +#ifndef RESPAWN_THRESHOLD_DEFAULT +#define RESPAWN_THRESHOLD_DEFAULT 3600 +#endif + +#ifndef RESPAWN_TIMEOUT_DEFAULT +#define RESPAWN_TIMEOUT_DEFAULT 5 +#endif + +#ifndef RESPAWN_RETRY_DEFAULT +#define RESPAWN_RETRY_DEFAULT 5 +#endif struct jail { bool procfs;