[exim-cvs] Build: probe for broken poll() timing implementat…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Exim Git Commits Mailing List
Dátum:  
Címzett: exim-cvs
Tárgy: [exim-cvs] Build: probe for broken poll() timing implementation
Gitweb: https://git.exim.org/exim.git/commitdiff/02c30a32c6d1aeab0d3bc5f747016041a687c9dd
Commit:     02c30a32c6d1aeab0d3bc5f747016041a687c9dd
Parent:     590faf89a2dd33a5f97f8e685efd019ac9c96e1e
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Tue Oct 23 22:25:40 2018 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Tue Oct 23 22:27:43 2018 +0100


    Build: probe for broken poll() timing implementation
---
 src/OS/os.h-Darwin           |  4 +---
 src/src/acl.c                | 22 +++++++++++-----------
 src/src/buildconfig.c        | 21 +++++++++++++++++++++
 test/scripts/0000-Basic/0609 |  1 +
 4 files changed, 34 insertions(+), 14 deletions(-)


diff --git a/src/OS/os.h-Darwin b/src/OS/os.h-Darwin
index d0a1a09..67aeac9 100644
--- a/src/OS/os.h-Darwin
+++ b/src/OS/os.h-Darwin
@@ -7,8 +7,6 @@
#define PAM_H_IN_PAM
#define SIOCGIFCONF_GIVES_ADDR

-/* OSX 10.2 does not have poll.h, 10.3 does emulate it badly. */
-#define NO_POLL_H

 #define F_FREESP     O_TRUNC
 typedef struct flock flock_t;
@@ -17,7 +15,7 @@ typedef struct flock flock_t;
                                Consider reducing MAX_LOCALHOST_NUMBER */


 #ifndef        _BSD_SOCKLEN_T_
-#define _BSD_SOCKLEN_T_ int32_t                 /* socklen_t (duh) */
+# define _BSD_SOCKLEN_T_ int32_t                 /* socklen_t (duh) */
 #endif


/* Settings for handling IP options. There's no netinet/ip_var.h. The IP
diff --git a/src/src/acl.c b/src/src/acl.c
index d4d370f..6cce0aa 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -3404,7 +3404,7 @@ for (; cb; cb = cb->next)

         else
           {
-          if (smtp_out != NULL && !f.disable_delay_flush)
+          if (smtp_out && !f.disable_delay_flush)
         mac_smtp_fflush();


 #if !defined(NO_POLL_H) && defined (POLLRDHUP)
@@ -3421,16 +3421,16 @@ for (; cb; cb = cb->next)
           HDEBUG(D_acl) debug_printf_indent("delay cancelled by peer close\n");
         }
 #else
-        /* It appears to be impossible to detect that a TCP/IP connection has
-        gone away without reading from it. This means that we cannot shorten
-        the delay below if the client goes away, because we cannot discover
-        that the client has closed its end of the connection. (The connection
-        is actually in a half-closed state, waiting for the server to close its
-        end.) It would be nice to be able to detect this state, so that the
-        Exim process is not held up unnecessarily. However, it seems that we
-        can't. The poll() function does not do the right thing, and in any case
-        it is not always available.
-        */
+      /* Lacking POLLRDHUP it appears to be impossible to detect that a
+      TCP/IP connection has gone away without reading from it. This means
+      that we cannot shorten the delay below if the client goes away,
+      because we cannot discover that the client has closed its end of the
+      connection. (The connection is actually in a half-closed state,
+      waiting for the server to close its end.) It would be nice to be able
+      to detect this state, so that the Exim process is not held up
+      unnecessarily. However, it seems that we can't. The poll() function
+      does not do the right thing, and in any case it is not always
+      available.  */


           while (delay > 0) delay = sleep(delay);
 #endif
diff --git a/src/src/buildconfig.c b/src/src/buildconfig.c
index 310798f..3d404f1 100644
--- a/src/src/buildconfig.c
+++ b/src/src/buildconfig.c
@@ -36,6 +36,8 @@ normally called independently. */
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <sys/time.h>
+#include <poll.h>
 #include <pwd.h>
 #include <grp.h>


@@ -956,6 +958,25 @@ if (have_auth)
     "#define SUPPORT_CRYPTEQ\n");
   }


+/* Check poll() for timer functionality.
+Some OS' have released with it broken. */
+
+  {
+  struct timeval before, after;
+  int rc;
+  size_t us;
+
+  gettimeofday(&before, NULL);
+  rc = poll(NULL, 0, 500);
+  gettimeofday(&after, NULL);
+
+  us = (after.tv_sec - before.tv_sec) * 1000000 +
+    (after.tv_usec - before.tv_usec);
+
+  if (us < 400000)
+    fprintf(new, "#define NO_POLL_H\n");
+  }
+
 /* End off */


fprintf(new, "\n/* End of config.h */\n");
diff --git a/test/scripts/0000-Basic/0609 b/test/scripts/0000-Basic/0609
index ea83bbf..86f7532 100644
--- a/test/scripts/0000-Basic/0609
+++ b/test/scripts/0000-Basic/0609
@@ -4,6 +4,7 @@ need_ipv4
#
# We want the debug note of a truncated delay
# "delay cancelled by peer close"
+# This is known to fail on MacOS, which lacks the require POLLRDHUP.
#
exim -d-all+acl -DSERVER=server -odq -bd -oX PORT_D
****