# Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: henrik@henriknordstrom.net-20100511013541-\ # 1v1dnocxttvwqv82 # target_branch: http://squid-cache.org/bzr/squid3/branches/SQUID_3_1/ # testament_sha1: 261b470e0c4b4451cc5e5541e62463f5d59456dd # timestamp: 2010-05-11 03:35:58 +0200 # base_revision_id: squid3@treenet.co.nz-20100505074245-\ # qpjwdvcumn8f94bd # # Begin patch === modified file 'src/comm.cc' --- src/comm.cc 2010-04-23 01:17:20 +0000 +++ src/comm.cc 2010-05-11 01:35:41 +0000 @@ -968,9 +968,6 @@ int ConnectStateData::commResetFD() { - struct addrinfo *AI = NULL; - IpAddress nul; - int new_family = AF_UNSPEC; // XXX: do we have to check this? // @@ -979,21 +976,19 @@ statCounter.syscalls.sock.sockets++; - /* setup a bare-bones addrinfo */ - /* TODO INET6: for WinXP we may need to check the local_addr type and setup the family properly. */ - nul.GetAddrInfo(AI); - new_family = AI->ai_family; + fde *F = &fd_table[fd]; + struct addrinfo *AI = NULL; + F->local_addr.GetAddrInfo(AI); int fd2 = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol); - nul.FreeAddrInfo(AI); - if (fd2 < 0) { debugs(5, DBG_CRITICAL, HERE << "WARNING: FD " << fd2 << " socket failed to allocate: " << xstrerror()); if (ENFILE == errno || EMFILE == errno) fdAdjustReserved(); + F->local_addr.FreeAddrInfo(AI); return 0; } @@ -1013,17 +1008,15 @@ close(fd2); + F->local_addr.FreeAddrInfo(AI); return 0; } commResetSelect(fd); close(fd2); - fde *F = &fd_table[fd]; - - /* INET6: copy the new sockets family type to the FDE table */ - fd_table[fd].sock_family = new_family; - - fd_table[fd].flags.called_connect = 0; + + F->flags.called_connect = 0; + /* * yuck, this has assumptions about comm_open() arguments for * the original socket @@ -1034,9 +1027,6 @@ comm_set_transparent(fd); } - AI = NULL; - F->local_addr.GetAddrInfo(AI); - if (commBind(fd, *AI) != COMM_OK) { debugs(5, DBG_CRITICAL, "WARNING: Reset of FD " << fd << " for " << F->local_addr << " failed to bind: " << xstrerror()); F->local_addr.FreeAddrInfo(AI); @@ -1104,8 +1094,7 @@ void ConnectStateData::connect() { - if (S.IsAnyAddr()) - defaults(); + defaults(); debugs(5,5, HERE << "to " << S); @@ -1125,10 +1114,18 @@ #if USE_IPV6 case COMM_ERR_PROTOCOL: /* problem using the desired protocol over this socket. - * count the connection attempt, reset the socket, and immediately try again */ + * skip to the next address and hope it's more compatible + * but do not mark the current address as bad + */ tries++; - commResetFD(); - connect(); + if (commRetryConnect()) { + /* Force an addr cycle to move forward to the next possible address */ + ipcacheCycleAddr(host, NULL); + eventAdd("commReconnect", commReconnect, this, this->addrcount == 1 ? 0.05 : 0.0, 0); + } else { + debugs(5, 5, HERE << "FD " << fd << ": * - ERR tried too many times already."); + callCallback(COMM_ERR_CONNECT, errno); + } break; #endif @@ -1232,7 +1229,6 @@ debugs(5, 9, "comm_connect_addr: connecting socket " << sock << " to " << address << " (want family: " << F->sock_family << ")"); - /* BUG 2222 FIX: reset the FD when its found to be IPv4 in IPv6 mode */ /* inverse case of IPv4 failing to connect on IPv6 socket is handeld post-connect. * this case must presently be handled here since the GetAddrInfo asserts on bad mappings. * eventually we want it to throw a Must() that gets handled there instead of this if. # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWX4OKCkAAmzfgEZQUff////n lgq////6UAU4q9N3VLgLrBXOQJIkNEGjTKaYBU/1Gkwp+ST9Q9NE0ZQPU2gmgSUCYTUybUT1T1PU fqRtQAA0ANAAAAlNIJoKbJTymzVDyJjUNHpNABoA0NNA9Q4yZNGIYmmAgYE0wRgmJppoAMIJJEwK YU/U1T9TUGjahoGgYmg0yAAAJDB28+jHXGxZ90YN00xKUliRRGB0T6N0UrrWoJrFvaNcIhqQWu5k TD8F/DZbNWRd6q8wzDTGDl4zk6fhZ3vzjjx8J8cEwJMbKcv3yfUbfOuu+UdEdKhi6Sm4ljN4Ga5n Ymkwbbks5M1F1wZn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