author | Olivier Brunel
<jjk@jjacky.com> 2017-01-27 18:50:50 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2017-06-18 12:30:05 UTC |
parent | 02b4f82078c72ada38869777770b5690ea869077 |
doc/aa-stop.pod | +5 | -1 |
src/anopa/aa-stop.c | +7 | -1 |
src/libanopa/service.c | +5 | -0 |
diff --git a/doc/aa-stop.pod b/doc/aa-stop.pod index 5384f74..6bf0755 100644 --- a/doc/aa-stop.pod +++ b/doc/aa-stop.pod @@ -20,7 +20,7 @@ entire supervised tree (i.e. be used during stage 3, after B<s6-svscan> has been brought down). When used, you shouldn't specify any service on the command line. -Also see below for more implications. +Also see below as well as B<--timeout> for more implications. =item B<-D, --double-output> @@ -62,6 +62,10 @@ for. Set default timeout to I<timeout> seconds. You can use 0 for no timeout. Timeout can also be set in service in a file I<timeout> in its servicedir. +If the "stop-all" mode is enabled (i.e. option B<--all> used twice), the default +timeout (whether or not set on command line) will also be used as a maximum +value. + =item B<-V, --version> Show version information and exit. diff --git a/src/anopa/aa-stop.c b/src/anopa/aa-stop.c index fc317f3..2d89ddc 100644 --- a/src/anopa/aa-stop.c +++ b/src/anopa/aa-stop.c @@ -2,7 +2,7 @@ * anopa - Copyright (C) 2015-2017 Olivier Brunel * * aa-stop.c - * Copyright (C) 2015-2016 Olivier Brunel <jjk@jjacky.com> + * Copyright (C) 2015-2017 Olivier Brunel <jjk@jjacky.com> * * This file is part of anopa. * @@ -393,6 +393,12 @@ main (int argc, char * const argv[]) if ((all && (path_list || argc > 0)) || (!all && !path_list && argc < 1)) dieusage (1); + if ((mode & AA_MODE_STOP_ALL) && aa_secs_timeout == 0) + { + aa_strerr_warn1x ("Default timeout cannot be infinite (0) in stop-all mode, ignoring"); + aa_secs_timeout = DEFAULT_TIMEOUT_SECS; + } + if (aa_init_repo (path_repo, (mode & AA_MODE_IS_DRY) ? AA_REPO_READ : AA_REPO_WRITE) < 0) aa_strerr_diefu2sys (ERR_IO, "init repository ", path_repo); diff --git a/src/libanopa/service.c b/src/libanopa/service.c index 993bbb1..0627d10 100644 --- a/src/libanopa/service.c +++ b/src/libanopa/service.c @@ -390,6 +390,11 @@ aa_ensure_service_loaded (int si, aa_mode mode, int no_wants, aa_autoload_cb al_ aa_strerr_warnu3x ("read timeout for ", aa_service_name (aa_service (si)), "; using default"); aa_service (si)->secs_timeout = aa_secs_timeout; } + /* in STOP_ALL the default is also a maximum */ + else if ((mode & AA_MODE_STOP_ALL) + && (aa_service (si)->secs_timeout > aa_secs_timeout + || aa_service (si)->secs_timeout == 0)) + aa_service (si)->secs_timeout = aa_secs_timeout; } else aa_service (si)->secs_timeout = aa_secs_timeout;