about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-06-07 13:23:15 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-06-07 13:23:15 +0000
commit9cef1c1af7d7c82f96930f4fcfead330981ad248 (patch)
tree7216f87f5da3b6f72b6e0096c003b3a8e5cf9111
parent76531c14c0b6cbec370afeece25b43525dadbecd (diff)
downloadsmtpd-starttls-proxy-9cef1c1af7d7c82f96930f4fcfead330981ad248.tar.gz
smtpd-starttls-proxy-9cef1c1af7d7c82f96930f4fcfead330981ad248.tar.xz
smtpd-starttls-proxy-9cef1c1af7d7c82f96930f4fcfead330981ad248.zip
Time out after 5 minutes, not 5000 minutes >.>
-rw-r--r--src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c b/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c
index fe67895..fcb1abd 100644
--- a/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c
+++ b/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c
@@ -24,12 +24,11 @@
 
 #define USAGE "smtpd-starttls-proxy-io [ -- ] prog..."
 #define dieusage() strerr_dieusage(100, USAGE)
-#define dienomem() strerr_diefu1sys(111, "alloc")
 
 #define INSIZE 1024
 #define OUTSIZE 1920
 
-#define reset_timeout() tain_addsec_g(&deadline, 300000)
+#define reset_timeout() tain_addsec_g(&deadline, 300)
 
 static int fdctl ;
 static int sslfds[2] ;
@@ -260,21 +259,24 @@ static void child (int fdr, int fdw)
 
     if (x[1].events & x[1].revents & IOPAUSE_WRITE)
     {
-      reset_timeout() ;
-      if (!buffer_flush(&io[0].out) && !error_isagain(errno))
-        strerr_diefu1sys(111, "write to client") ;
+      if (!buffer_flush(&io[0].out))
+      {
+        if (error_isagain(errno)) strerr_diefu1sys(111, "write to client") ;
+      }
+      else reset_timeout() ;
     }
 
     if (x[3].events & x[3].revents & IOPAUSE_WRITE)
     {
-      reset_timeout() ;
-      if (!buffer_flush(&io[1].out) && !error_isagain(errno))
-        strerr_diefu1sys(111, "write to server") ;
+      if (!buffer_flush(&io[1].out))
+      {
+        if (!error_isagain(errno)) strerr_diefu1sys(111, "write to server") ;
+      }
+      else reset_timeout() ;
     }
 
     if (x[2].revents & IOPAUSE_READ)
     {
-      reset_timeout() ;
       for (;;)
       {
         int r = getlnmax(&io[1].in, io[1].line, INSIZE - 1, &io[1].w, '\n') ;
@@ -291,6 +293,7 @@ static void child (int fdr, int fdw)
           break ;
         }
         io[1].line[io[1].w] = 0 ;
+        reset_timeout() ;
         process_server_line(io[1].line) ;
         io[1].w = 0 ;
       }
@@ -298,7 +301,6 @@ static void child (int fdr, int fdw)
 
     if (x[0].revents & IOPAUSE_READ)
     {
-      reset_timeout() ;
       for (;;)
       {
         int r = getlnmax(&io[0].in, io[0].line, INSIZE - 1, &io[0].w, '\n') ;
@@ -310,6 +312,7 @@ static void child (int fdr, int fdw)
         }
         if (!r) _exit(0) ;
         io[0].line[io[0].w] = 0 ;
+        reset_timeout() ;
         if (process_client_line(io[0].line)) break ;
         io[0].w = 0 ;
       }