[exim-cvs] Fix spurious logging of select error

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Exim Git Commits Mailing List
Fecha:  
A: exim-cvs
Asunto: [exim-cvs] Fix spurious logging of select error
Gitweb: https://git.exim.org/exim.git/commitdiff/f0ce96bbcfba66911b5ab36719638a52474301a9
Commit:     f0ce96bbcfba66911b5ab36719638a52474301a9
Parent:     65fe26cc962035dbe3b4462f330f6959c3b78417
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Tue Nov 3 13:14:11 2020 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Tue Nov 3 13:14:11 2020 +0000


    Fix spurious logging of select error
---
 doc/doc-txt/ChangeLog |  6 ++++++
 src/src/daemon.c      | 53 +++++++++++++++++++++++----------------------------
 2 files changed, 30 insertions(+), 29 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index e61ad62..d56454c 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -134,6 +134,12 @@ JH/27 Bug 2648: fix the passing of an authenticator public-name through spool
       files.  The value is used by the authresults expansion item.  Previously
       if this was used in a router or transport, a crash could result.


+JH/28 Fix spurious logging of select error.  Some platforms, notably FreeBSD,
+      have a sufficient incidence of EINTR returns from select that an
+      interaction with other operations done by the main daemon loop exposed
+      a bug in the error-handling.  This was benign apart from the log
+      messages.
+


Exim version 4.94
-----------------
diff --git a/src/src/daemon.c b/src/src/daemon.c
index 78a4d8e..83131fa 100644
--- a/src/src/daemon.c
+++ b/src/src/daemon.c
@@ -2278,7 +2278,7 @@ for (;;)

   if (f.daemon_listen)
     {
-    int lcount, select_errno;
+    int lcount;
     int max_socket = 0;
     BOOL select_failed = FALSE;
     fd_set select_listen;
@@ -2333,14 +2333,16 @@ for (;;)
     old one had just finished. Preserve the errno from any select() failure for
     the use of the common select/accept error processing below. */


-    select_errno = errno;
-    handle_ending_processes();
-    errno = select_errno;
+      {
+      int select_errno = errno;
+      handle_ending_processes();


 #ifndef DISABLE_TLS
-    /* Create or rotate any required keys; handle (delayed) filewatch event */
-    tls_daemon_tick();
+      /* Create or rotate any required keys; handle (delayed) filewatch event */
+      tls_daemon_tick();
 #endif
+      errno = select_errno;
+      }


     /* Loop for all the sockets that are currently ready to go. If select
     actually failed, we have set the count to 1 and select_failed=TRUE, so as
@@ -2396,40 +2398,33 @@ for (;;)
           accept_retry_errno = errno;
           accept_retry_select_failed = select_failed;
           }
-        else
-          {
-          if (errno != accept_retry_errno ||
-              select_failed != accept_retry_select_failed ||
-              accept_retry_count >= 50)
+        else if (  errno != accept_retry_errno 
+        || select_failed != accept_retry_select_failed
+        || accept_retry_count >= 50)
             {
-            log_write(0, LOG_MAIN | ((accept_retry_count >= 50)? LOG_PANIC : 0),
+            log_write(0, LOG_MAIN | (accept_retry_count >= 50 ? LOG_PANIC : 0),
               "%d %s() failure%s: %s",
               accept_retry_count,
-              accept_retry_select_failed? "select" : "accept",
-              (accept_retry_count == 1)? "" : "s",
+              accept_retry_select_failed ? "select" : "accept",
+              accept_retry_count == 1 ? "" : "s",
               strerror(accept_retry_errno));
             log_close_all();
             accept_retry_count = 0;
             accept_retry_errno = errno;
             accept_retry_select_failed = select_failed;
             }
-          }
         accept_retry_count++;
         }
-
-      else
-        {
-        if (accept_retry_count > 0)
-          {
-          log_write(0, LOG_MAIN, "%d %s() failure%s: %s",
-            accept_retry_count,
-            accept_retry_select_failed? "select" : "accept",
-            (accept_retry_count == 1)? "" : "s",
-            strerror(accept_retry_errno));
-          log_close_all();
-          accept_retry_count = 0;
-          }
-        }
+      else if (accept_retry_count > 0)
+    {
+    log_write(0, LOG_MAIN, "%d %s() failure%s: %s",
+      accept_retry_count,
+      accept_retry_select_failed ? "select" : "accept",
+      accept_retry_count == 1 ? "" : "s",
+      strerror(accept_retry_errno));
+    log_close_all();
+    accept_retry_count = 0;
+    }


       /* If select/accept succeeded, deal with the connection. */