From 8f00f3a276b4fde40bcd0ddaa4dc89d2b5791d89 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 19 Aug 2021 01:21:07 +0000 Subject: Fix lameduck timeout in s6-socklog Signed-off-by: Laurent Bercot --- src/daemontools-extras/s6-socklog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/daemontools-extras') diff --git a/src/daemontools-extras/s6-socklog.c b/src/daemontools-extras/s6-socklog.c index f261916..c2d0aa8 100644 --- a/src/daemontools-extras/s6-socklog.c +++ b/src/daemontools-extras/s6-socklog.c @@ -37,7 +37,10 @@ static inline void handle_signals (void) { case -1 : strerr_diefu1sys(111, "selfpipe_read()") ; case 0 : return ; - case SIGTERM : cont = 0 ; break ; + case SIGTERM : + cont = 0 ; + tain_add_g(&lameducktto, &lameducktto) ; + break ; default : break ; } } @@ -104,7 +107,6 @@ int main (int argc, char const *const *argv) if (linelen < 80) linelen = 80 ; if (linelen > 1048576) linelen = 1048576 ; if (t) tain_from_millisecs(&lameducktto, t) ; - else lameducktto = tain_infinite_relative ; if (notif) { if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ; @@ -161,12 +163,10 @@ int main (int argc, char const *const *argv) char line[linelen + 1] ; while (cont || buffer_len(&b1)) { - tain deadline = TAIN_INFINITE ; ssize_t r ; - if (!cont) tain_add_g(&deadline, &lameducktto) ; x[1].events = buffer_len(&b1) ? IOPAUSE_WRITE : 0 ; x[2].events = cont && buffer_available(&b1) >= linelen + 80 ? IOPAUSE_READ : 0 ; - r = iopause_g(x, 3, &deadline) ; + r = iopause_g(x, 3, cont ? &tain_infinite : &lameducktto) ; if (r == -1) strerr_diefu1sys(111, "iopause") ; if (!r) return 99 ; if (x[0].revents & IOPAUSE_READ) handle_signals() ; -- cgit v1.2.3