]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
comm_connect_addr on failures returns Comm:OK
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Fri, 8 May 2015 19:16:22 +0000 (12:16 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 8 May 2015 19:16:22 +0000 (12:16 -0700)
The comm_connect_addr on connect failures sets the xerrno to 0
and returns Comm::OK. This is causes problems on ConnOpener
class users which believes the connection is established and
it is ready for use.

 This is a Measurement Factory project

src/comm.cc

index 8a110b84d370fe52be15345c41b302bd00fadf6b..54a13441dcdb96c2fd0fde2801c4e898315ffbb1 100644 (file)
@@ -632,24 +632,24 @@ comm_connect_addr(int sock, const Ip::Address &address)
         F->flags.called_connect = true;
         ++ statCounter.syscalls.sock.connects;
 
-        x = connect(sock, AI->ai_addr, AI->ai_addrlen);
-
-        // XXX: ICAP code refuses callbacks during a pending comm_ call
-        // Async calls development will fix this.
-        if (x == 0) {
-            x = -1;
-            xerrno = EINPROGRESS;
-        } else if (x < 0) {
-            debugs(5,5, "comm_connect_addr: sock=" << sock << ", addrinfo( " <<
+        errno = 0;
+        if ((x = connect(sock, AI->ai_addr, AI->ai_addrlen)) < 0) {
+            xerrno = errno;
+            debugs(5,5, "sock=" << sock << ", addrinfo(" <<
                    " flags=" << AI->ai_flags <<
                    ", family=" << AI->ai_family <<
                    ", socktype=" << AI->ai_socktype <<
                    ", protocol=" << AI->ai_protocol <<
                    ", &addr=" << AI->ai_addr <<
-                   ", addrlen=" << AI->ai_addrlen <<
-                   " )" );
+                   ", addrlen=" << AI->ai_addrlen << " )");
             debugs(5, 9, "connect FD " << sock << ": (" << x << ") " << xstrerr(xerrno));
-            debugs(14,9, "connecting to: " << address );
+            debugs(14,9, "connecting to: " << address);
+
+        } else if (x == 0) {
+            // XXX: ICAP code refuses callbacks during a pending comm_ call
+            // Async calls development will fix this.
+            x = -1;
+            xerrno = EINPROGRESS;
         }
 
     } else {