about summary refs log tree commit diff
path: root/src/daemontools-extras
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-08-19 01:21:07 +0000
committerLaurent Bercot <ska@appnovation.com>2021-08-19 01:21:07 +0000
commit8f00f3a276b4fde40bcd0ddaa4dc89d2b5791d89 (patch)
tree3ba82d0c984dca69c4a845bb3d636c5e4b24d743 /src/daemontools-extras
parent464803b4b69f63a8b0bf7e5676ecdad065ac400a (diff)
downloads6-8f00f3a276b4fde40bcd0ddaa4dc89d2b5791d89.tar.gz
s6-8f00f3a276b4fde40bcd0ddaa4dc89d2b5791d89.tar.xz
s6-8f00f3a276b4fde40bcd0ddaa4dc89d2b5791d89.zip
Fix lameduck timeout in s6-socklog
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/daemontools-extras')
-rw-r--r--src/daemontools-extras/s6-socklog.c10
1 files changed, 5 insertions, 5 deletions
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() ;