diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2018-10-23 22:25:40 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2018-10-23 22:27:43 +0100 |
commit | 02c30a32c6d1aeab0d3bc5f747016041a687c9dd (patch) | |
tree | 8c5ac4b5c60c32235d600f47015f095dbf891553 /src | |
parent | 590faf89a2dd33a5f97f8e685efd019ac9c96e1e (diff) |
Build: probe for broken poll() timing implementation
Diffstat (limited to 'src')
-rw-r--r-- | src/OS/os.h-Darwin | 4 | ||||
-rw-r--r-- | src/src/acl.c | 22 | ||||
-rw-r--r-- | src/src/buildconfig.c | 21 |
3 files changed, 33 insertions, 14 deletions
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 <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"); |