From: Christos Tsantilas Date: Fri, 8 May 2015 19:16:22 +0000 (-0700) Subject: comm_connect_addr on failures returns Comm:OK X-Git-Tag: merge-candidate-3-v1~129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07383e119833e0f6e6a61377b8d9d2b231fdf90b;p=thirdparty%2Fsquid.git comm_connect_addr on failures returns Comm:OK 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 --- diff --git a/src/comm.cc b/src/comm.cc index 8a110b84d3..54a13441dc 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -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 {