From ded312bcc44704ea16fdfe9fb9f2b46bfd0f537b Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 27 Mar 2017 14:05:21 +0000 Subject: Clarify permanent failure API for s6-svwait -r and friends; update doc --- src/supervision/s6-svlisten.c | 19 +++++++------------ src/supervision/s6-svlisten1.c | 19 +++++++------------ src/supervision/s6_svlisten_loop.c | 9 ++++++--- 3 files changed, 20 insertions(+), 27 deletions(-) (limited to 'src/supervision') diff --git a/src/supervision/s6-svlisten.c b/src/supervision/s6-svlisten.c index d15557a..7e1b930 100644 --- a/src/supervision/s6-svlisten.c +++ b/src/supervision/s6-svlisten.c @@ -30,12 +30,12 @@ int main (int argc, char const **argv, char const *const *envp) if (opt == -1) break ; switch (opt) { - case 'u' : wantup = 1 ; wantready = 0 ; break ; - case 'U' : wantup = 1 ; wantready = 1 ; break ; - case 'd' : wantup = 0 ; wantready = 0 ; break ; - case 'D' : wantup = 0 ; wantready = 1 ; break ; - case 'r' : wantrestart = 1 ; wantready = 0 ; break ; - case 'R' : wantrestart = 1 ; wantready = 1 ; break ; + case 'u' : wantup = 1 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'U' : wantup = 1 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'd' : wantup = 0 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'D' : wantup = 0 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'r' : wantup = 1 ; wantrestart = 1 ; wantready = 0 ; break ; + case 'R' : wantup = 1 ; wantrestart = 1 ; wantready = 1 ; break ; case 'a' : or = 0 ; break ; case 'o' : or = 1 ; break ; case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; @@ -70,12 +70,7 @@ int main (int argc, char const **argv, char const *const *envp) s6_svlisten_init(argc1, argv, &foo, ids, upstate, readystate, &deadline) ; pid = child_spawn0(argv[argc1 + 1], argv + argc1 + 1, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[argc1 + 1]) ; - if (wantrestart) - { - e = s6_svlisten_loop(&foo, 0, 1, or, &deadline, spfd, &s6_svlisten_signal_handler) ; - if (e) strerr_dief1x(e, "some services reported permanent failure") ; - wantup = 1 ; - } + if (wantrestart) s6_svlisten_loop(&foo, 0, 1, or, &deadline, spfd, &s6_svlisten_signal_handler) ; e = s6_svlisten_loop(&foo, wantup, wantready, or, &deadline, spfd, &s6_svlisten_signal_handler) ; if (e) strerr_dief1x(e, "some services reported permanent failure") ; } diff --git a/src/supervision/s6-svlisten1.c b/src/supervision/s6-svlisten1.c index af9959a..62afc15 100644 --- a/src/supervision/s6-svlisten1.c +++ b/src/supervision/s6-svlisten1.c @@ -31,12 +31,12 @@ int main (int argc, char const *const *argv, char const *const *envp) if (opt == -1) break ; switch (opt) { - case 'u' : wantup = 1 ; wantready = 0 ; break ; - case 'U' : wantup = 1 ; wantready = 1 ; break ; - case 'd' : wantup = 0 ; wantready = 0 ; break ; - case 'D' : wantup = 0 ; wantready = 1 ; break ; - case 'r' : wantrestart = 1 ; wantready = 0 ; break ; - case 'R' : wantrestart = 1 ; wantready = 1 ; break ; + case 'u' : wantup = 1 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'U' : wantup = 1 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'd' : wantup = 0 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'D' : wantup = 0 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'r' : wantup = 1 ; wantrestart = 1 ; wantready = 0 ; break ; + case 'R' : wantup = 1 ; wantrestart = 1 ; wantready = 1 ; break ; case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; default : dieusage() ; } @@ -51,12 +51,7 @@ int main (int argc, char const *const *argv, char const *const *envp) s6_svlisten_init(1, argv, &foo, &id, &upstate, &readystate, &deadline) ; pid = child_spawn0(argv[1], argv + 1, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[1]) ; - if (wantrestart) - { - int e = s6_svlisten_loop(&foo, 0, 1, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; - if (e) strerr_dief2x(1, argv[0], " failed permanently: the finish script exited 125") ; - wantup = 1 ; - } + if (wantrestart) s6_svlisten_loop(&foo, 0, 1, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; e = s6_svlisten_loop(&foo, wantup, wantready, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; if (e) strerr_dief2x(1, argv[0], " failed permanently: the finish script exited 125") ; return 0 ; diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c index d2e776a..5c55c81 100644 --- a/src/supervision/s6_svlisten_loop.c +++ b/src/supervision/s6_svlisten_loop.c @@ -67,9 +67,12 @@ int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, int or, tai { if (what == 'O') { - bitarray_poke(foo->upstate, i, wantup) ; - bitarray_poke(foo->readystate, i, wantready) ; - e++ ; + if (wantup) + { + bitarray_poke(foo->upstate, i, wantup) ; + bitarray_poke(foo->readystate, i, wantready) ; + e++ ; + } } else { -- cgit v1.2.3