From 5973b4be33ee22dc4e8bb01ecc612eb7aaef3937 Mon Sep 17 00:00:00 2001 From: Christos Tsantilas Date: Sat, 9 May 2015 04:51:06 -0700 Subject: [PATCH] comm_connect_addr on failures returns Comm:OK NOTE: regression from bug 4324 patch in rev.13811 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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) 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 { -- 2.47.2