From: Fabian Keil Date: Thu, 8 Jun 2017 13:04:56 +0000 (+0000) Subject: rfc2553_connect_to(): Properly detect and log when poll() reached the time out X-Git-Tag: v_3_0_27~131 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=2b104746c8c7a4d05d79de0e630467751d0a4128 rfc2553_connect_to(): Properly detect and log when poll() reached the time out Previously this was logged as: Could not connect to [...]: No error: 0. which isn't very helpful. The select() code path doesn't look like it would handle timeouts properly either but apparently nobody noticed this yet ... Sponsored by: Robert Klemme --- diff --git a/jbsockets.c b/jbsockets.c index 3c43c177..72149790 100644 --- a/jbsockets.c +++ b/jbsockets.c @@ -1,4 +1,4 @@ -const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.143 2017/06/04 14:37:05 fabiankeil Exp $"; +const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.144 2017/06/08 13:04:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $ @@ -373,7 +373,26 @@ static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client poll_fd[0].fd = fd; poll_fd[0].events = POLLOUT; - if (poll(poll_fd, 1, 30000) > 0) + retval = poll(poll_fd, 1, 30000); + if (retval == 0) + { + if (rp->ai_next != NULL) + { + /* Log this now as we'll try another address next */ + log_error(LOG_LEVEL_CONNECT, + "Could not connect to [%s]:%s: Operation timed out.", + csp->http->host_ip_addr_str, service); + } + else + { + /* + * This is the last address, don't log this now + * as it would result in a duplicated log message. + */ + socket_error = ETIMEDOUT; + } + } + else if (retval > 0) #else /* wait for connection to complete */ FD_ZERO(&wfds);