From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 6C0FA138916 for ; Fri, 8 Feb 2013 17:33:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7FA47E055E; Fri, 8 Feb 2013 17:33:02 +0000 (UTC) Received: from mail.xunit.de (mail.xunit.de [178.33.39.247]) by pigeon.gentoo.org (Postfix) with ESMTP id 99CD3E055C for ; Fri, 8 Feb 2013 17:33:01 +0000 (UTC) Received: from me.fritz.box (p57B53CD1.dip.t-dialin.net [87.181.60.209]) by mail.xunit.de (Postfix) with ESMTPSA id 81AE178070 for ; Fri, 8 Feb 2013 18:32:54 +0100 (CET) Date: Fri, 8 Feb 2013 18:33:10 +0100 From: assabajanischer_hinterwaeldler@xunit.de To: gentoo-user-de@lists.gentoo.org Subject: Re: [gentoo-user-de] Temporaere erhoehung destTimeoutlimits in initskripten (openrc) Message-ID: <20130208173310.GB7609@me.fritz.box> References: <20130201193817.GA2523@me.fritz.box> <510D674F.8070608@m120.de> <20130204222223.GA5040@me.fritz.box> <20130205134939.GA3714@localhost> <511142B7.4020704@googlemail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user-de@lists.gentoo.org Reply-to: gentoo-user-de@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <511142B7.4020704@googlemail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Archives-Salt: 05f23cda-6145-4ea3-92a2-79fd50dee29a X-Archives-Hash: 377e03557690724798ee36183264bc28 --envbJBWh7q8WU6mo Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Feb 05, 2013 at 06:34:47PM +0100, Sandy Marko Knauer wrote: > Am 05.02.2013 14:49, schrieb assabajanischer_hinterwaeldler@xunit.de: > > hallo, > > > > hab jetzt ein wenig im openrc code geschmoekert. und ohne anpassung > > daran laesst sich das vermutlich nich realisieren. > > > > gruss > > martin > > > Hi, > > könnte einige Interessieren die dieses Thema verfolgt haben. > > http://dev.gentoo.org/~vapier/openrc/projects/openrc/ticket/125.html > > Sandy > geht glaub ich ein etwas andere richtung. zumindest scheint es mir so sollte ausser mir noch jemand interesse an einem derartigen timeout mechanismus haben, kann er den patch im anhang verwenden. ich hoff das ist ok, dass ich den einfach so anhaeng. dazu habe ich im depend bereich das schluesselwort 'mintime' definiert. anschliessen wird die zeit in sekunden angegeben, um die der timeoutmechansimus verzoegert wird. gruss martin --envbJBWh7q8WU6mo Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Allow-to-specify-a-minimum-service-handling-time.patch" >From b9b31ee3c746ef7b7b4260ee4816259b3950bb70 Mon Sep 17 00:00:00 2001 From: Hinterwaeldler Date: Fri, 8 Feb 2013 13:16:54 +0000 Subject: [PATCH] Allow to specify a minimum service handling time When a service is started their could be warnings due to larger processing time. To avoid the usage of the complete deactivation of the timeout mechanism a 'mintime' dependancy is introduced. During the given time the regular timeout mechanism is deactived. After the time expires the regular timeout is still able to kill the process if necessary. --- man/runscript.8 | 5 +++++ sh/gendepends.sh.in | 3 +++ src/rc/runscript.c | 51 +++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/man/runscript.8 b/man/runscript.8 index 044bef7..25a818a 100644 --- a/man/runscript.8 +++ b/man/runscript.8 @@ -191,6 +191,11 @@ Same as -jail, but for Xen DOM0 systems. .It Dv -xenu Same as -jail, but for Xen DOMU systems. .El +.It Ic mintime +Specify a minimum amount of time in seconds a service needs to complete. +During this time no timeout can occure (e.g. need more than 60 seconds). +After the given time expires, a timeout can occure. +This values only influence the timeout mechanism i.e. the service handling may use less time. .El .Pp To see how to influence dependencies in configuration files, see the diff --git a/sh/gendepends.sh.in b/sh/gendepends.sh.in index f78f3d3..987ad4b 100644 --- a/sh/gendepends.sh.in +++ b/sh/gendepends.sh.in @@ -31,6 +31,9 @@ keyword() { depend() { : } +mintime(){ + [ -n "$*" ] && echo "$RC_SVCNAME mintime $*" >&3 +} _done_dirs= for _dir in \ diff --git a/src/rc/runscript.c b/src/rc/runscript.c index e504e4a..16f7207 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -488,8 +488,11 @@ svc_wait(const char *svc) char file[PATH_MAX]; int fd; bool forever = false; - RC_STRINGLIST *keywords; - struct timespec interval, timeout, warn; + RC_STRINGLIST *keywords, *mintime_list; + struct timespec interval, timeout, warn, mintime; + RC_STRING *mintime_element; + char *conf_value, *mintime_check; + int conf_value_length, mintime_value = 0; /* Some services don't have a timeout, like fsck */ keywords = rc_deptree_depend(deptree, svc, "keyword"); @@ -498,6 +501,24 @@ svc_wait(const char *svc) forever = true; rc_stringlist_free(keywords); + /* Allow services to use a specified amount of time without warnings */ + mintime_list = rc_deptree_depend(deptree, svc, "mintime"); + if (mintime_list) { + mintime_element = TAILQ_FIRST(mintime_list); + if (mintime_element) { + conf_value = mintime_element->value; + conf_value_length = strlen(conf_value); + mintime_value = strtol(conf_value, &mintime_check, 10); + if (mintime_check != conf_value + conf_value_length || + mintime_value < 0) { + mintime_value = 0; + eerror("Invalid mintime definition: %s", + conf_value); + } + } + } + rc_stringlist_free(mintime_list); + snprintf(file, sizeof(file), RC_SVCDIR "/exclusive/%s", basename_c(svc)); @@ -507,6 +528,8 @@ svc_wait(const char *svc) timeout.tv_nsec = 0; warn.tv_sec = WARN_TIMEOUT; warn.tv_nsec = 0; + mintime.tv_sec = mintime_value; + mintime.tv_nsec = 0; for (;;) { fd = open(file, O_RDONLY | O_NONBLOCK); if (fd != -1) { @@ -526,15 +549,18 @@ svc_wait(const char *svc) return false; } if (!forever) { - timespecsub(&timeout, &interval, &timeout); - if (timeout.tv_sec <= 0) - return false; - timespecsub(&warn, &interval, &warn); - if (warn.tv_sec <= 0) { - ewarn("%s: waiting for %s (%d seconds)", - applet, svc, (int)timeout.tv_sec); - warn.tv_sec = WARN_TIMEOUT; - warn.tv_nsec = 0; + timespecsub(&mintime, &interval, &mintime); + if (mintime.tv_sec <= 0){ + timespecsub(&timeout, &interval, &timeout); + if (timeout.tv_sec <= 0) + return false; + timespecsub(&warn, &interval, &warn); + if (warn.tv_sec <= 0) { + ewarn("%s: waiting for %s (%d seconds)", + applet, svc, (int)timeout.tv_sec); + warn.tv_sec = WARN_TIMEOUT; + warn.tv_nsec = 0; + } } } } @@ -1348,9 +1374,6 @@ runscript(int argc, char **argv) applet_list, runlevel, depoptions); rc_stringlist_free(tmplist); - TAILQ_FOREACH(svc, services, entries) - printf("%s ", svc->value); - printf ("\n"); rc_stringlist_free(services); services = NULL; } else if (strcmp (optarg, "status") == 0) { -- 1.7.12.4 --envbJBWh7q8WU6mo--