From: Jeremy Harris Date: Tue, 23 Oct 2018 21:25:40 +0000 (+0100) Subject: Build: probe for broken poll() timing implementation X-Git-Tag: exim-4.92-RC1~59 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=02c30a32c6d1aeab0d3bc5f747016041a687c9dd;p=exim.git Build: probe for broken poll() timing implementation --- diff --git a/src/OS/os.h-Darwin b/src/OS/os.h-Darwin index d0a1a092f..67aeac913 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 d4d370f5e..6cce0aae6 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 310798fdd..3d404f100 100644 --- a/src/src/buildconfig.c +++ b/src/src/buildconfig.c @@ -36,6 +36,8 @@ normally called independently. */ #include #include #include +#include +#include #include #include @@ -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 ea83bbfba..86f75326f 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 ****