X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fip.c;h=08d32f21b382937f8f4974533e67bc9dc896cf3f;hb=2cee425af0f8c425a410ff12a51f05a175a0c80b;hp=b744f5d4c101b88e4c7fe1500d8fc3019d089c8d;hpb=fb05276aaee4c27b6f20fb1f32290ee40a929064;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/ip.c b/src/src/ip.c index b744f5d4c..08d32f21b 100644 --- a/src/src/ip.c +++ b/src/src/ip.c @@ -2,12 +2,12 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2016 */ +/* Copyright (c) University of Cambridge 1995 - 2017 */ /* See the file NOTICE for conditions of use and distribution. */ /* Functions for doing things with sockets. With the advent of IPv6 this has got messier, so that it's worth pulling out the code into separate functions -that other parts of Exim can call, expecially as there are now several +that other parts of Exim can call, especially as there are now several different places in the code where sockets are used. */ @@ -224,7 +224,7 @@ callout_address = string_sprintf("[%s]:%d", address, port); sigalrm_seen = FALSE; if (timeout > 0) alarm(timeout); -#ifdef TCP_FASTOPEN +#if defined(TCP_FASTOPEN) && defined(MSG_FASTOPEN) /* TCP Fast Open, if the system has a cookie from a previous call to this peer, can send data in the SYN packet. The peer can send data before it gets our ACK of its SYN,ACK - the latter is useful for @@ -235,14 +235,15 @@ connect in FASTOPEN mode but with zero data. if (fastopen) { - if ( (rc = sendto(sock, NULL, 0, MSG_FASTOPEN, s_ptr, s_len)) < 0 - && errno == EOPNOTSUPP - ) - { - log_write(0, LOG_MAIN|LOG_PANIC, - "Tried TCP Fast Open but apparently not enabled by sysctl"); - rc = connect(sock, s_ptr, s_len); - } + if ((rc = sendto(sock, NULL, 0, MSG_FASTOPEN | MSG_DONTWAIT, s_ptr, s_len)) < 0) + if (errno == EINPROGRESS) /* the expected case */ + rc = 0; + else if(errno == EOPNOTSUPP) + { + DEBUG(D_transport) + debug_printf("Tried TCP Fast Open but apparently not enabled by sysctl\n"); + rc = connect(sock, s_ptr, s_len); + } } else #endif @@ -303,6 +304,7 @@ int namelen, port; host_item shost; host_item *h; int af = 0, fd, fd4 = -1, fd6 = -1; +BOOL fastopen = tcp_fastopen_ok && type == SOCK_STREAM; shost.next = NULL; shost.address = NULL; @@ -358,7 +360,7 @@ for (h = &shost; h; h = h->next) } for(port = portlo; port <= porthi; port++) - if (ip_connect(fd, af, h->address, port, timeout, type == SOCK_STREAM) == 0) + if (ip_connect(fd, af, h->address, port, timeout, fastopen) == 0) { if (fd != fd6) close(fd6); if (fd != fd4) close(fd4); @@ -456,7 +458,7 @@ ip_keepalive(int sock, const uschar *address, BOOL torf) { int fodder = 1; if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, - (uschar *)(&fodder), sizeof(fodder)) != 0) + US (&fodder), sizeof(fodder)) != 0) log_write(0, LOG_MAIN, "setsockopt(SO_KEEPALIVE) on connection %s %s " "failed: %s", torf? "to":"from", address, strerror(errno)); } @@ -491,7 +493,7 @@ if (time_left <= 0) do { - struct timeval tv = { time_left, 0 }; + struct timeval tv = { .tv_sec = time_left, .tv_usec = 0 }; FD_ZERO (&select_inset); FD_SET (fd, &select_inset);