---------------------
PatchSet 5401 
Date: 2007/08/21 11:51:23
Author: amosjeffries
Branch: squid3-ipv6
Tag: (none) 
Log:
Fix transport error (part of a dead experiment slipped into CVS in error).
Added asserts to catch occasional overflow.
Fix local address and port not being store in connection details properly.

Members: 
	NOTES-IPv6:1.1.2.59->1.1.2.60 
	src/comm.cc:1.47.2.46->1.47.2.47 

Index: squid3/NOTES-IPv6
===================================================================
RCS file: /cvsroot/squid-sf//squid3/Attic/NOTES-IPv6,v
retrieving revision 1.1.2.59
retrieving revision 1.1.2.60
diff -u -r1.1.2.59 -r1.1.2.60
--- squid3/NOTES-IPv6	20 Aug 2007 11:53:14 -0000	1.1.2.59
+++ squid3/NOTES-IPv6	21 Aug 2007 11:51:23 -0000	1.1.2.60
@@ -1,4 +1,4 @@
-$Id: NOTES-IPv6,v 1.1.2.59 2007/08/20 11:53:14 amosjeffries Exp $
+$Id: NOTES-IPv6,v 1.1.2.60 2007/08/21 11:51:23 amosjeffries Exp $
 
 NP: Any problems with this version of squid please contact
 	squid3@treenet.co.nz for assistance.
@@ -114,30 +114,6 @@
 2007/08/20 00:14:41.486| WARNING: You should probably remove '::-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/::' from the ACL named 'all'
 
 
-THEN THERES THIS:
- 2007/08/20 23:46:41.507| ipcacheCycleAddr: www.google.co.nz now at 72.14.253.103 ( of 
-                                                                                       )
- 2007/.....
-
-
-AND THE "ENDPOINT NOT CONNECTED" ERROR
-
-<skip the usual port opening, message read, generate request for google and ... -->
-2007/08/20 23:46:41.508| comm_write: FD 20: sz 702: hndl 1: data 0x85bbbb8.
-2007/08/20 23:46:41.508| commConnectFree: FD 20
-2007/08/20 23:46:41.509| comm_read_try: FD 20, size 4094, retval -1, errno 107
-2007/08/20 23:46:41.509| comm_read_try: scheduling COMM_ERROR
-2007/08/20 23:46:41.509| commio_complete_callback: called for 20 (-1, 107)
-2007/08/20 23:46:41.509| commHandleWrite: FD 20: off 0, sz 702.
-2007/08/20 23:46:41.509| commHandleWrite: write() returns -1
-2007/08/20 23:46:41.509| commHandleWrite: FD 20: write failure: (32) Broken pipe.
-2007/08/20 23:46:41.509| commio_complete_callback: called for 20 (-1, 32)
-2007/08/20 23:46:41.509| commio_call_callback: called for 20
-2007/08/20 23:46:41.509| httpReadReply: FD 20: len 0.
-2007/08/20 23:46:41.509| httpReadReply: FD 20: read failure: (32) Broken pipe.
-2007/08/20 23:46:41.509| fwdFail: ERR_READ_ERROR "Bad Gateway"
-
-
 TODO:
 
 3       Push incremental patches to HEAD (on hold for 3.1 branch)
Index: squid3/src/comm.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm.cc,v
retrieving revision 1.47.2.46
retrieving revision 1.47.2.47
diff -u -r1.47.2.46 -r1.47.2.47
--- squid3/src/comm.cc	12 Aug 2007 09:18:54 -0000	1.47.2.46
+++ squid3/src/comm.cc	21 Aug 2007 11:51:25 -0000	1.47.2.47
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.47.2.46 2007/08/12 09:18:54 amosjeffries Exp $
+ * $Id: comm.cc,v 1.47.2.47 2007/08/21 11:51:25 amosjeffries Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -724,10 +724,12 @@
     int x = 0;
     struct addrinfo *AI = NULL;
 
-    from.InitAddrInfo(AI);
-
     debugs(5,8, "comm_udp_recvfrom: FD " << fd << " from " << from);
 
+    assert( NULL == AI );
+
+    from.InitAddrInfo(AI);
+
     x = recvfrom(fd, buf, len, flags, AI->ai_addr, &AI->ai_addrlen);
 
     from = *AI;
@@ -1317,7 +1319,7 @@
     debugs(5, 9, "comm_connect_addr: connecting socket " << sock << " to " << address << " (want family: " << F->sock_family <<
                  ") Old-State=" << fdc_table[sock].active);
 
-    address.GetAddrInfo(AI); //, F->sock_family);
+    address.GetAddrInfo(AI, F->sock_family);
 
     /* Establish connection. */
     errno = 0;
@@ -1454,10 +1456,13 @@
     }
 
     details.peer = *gai;
-    details.me.SetEmpty();
 
+    details.me.SetEmpty();
     getsockname(sock, gai->ai_addr, &gai->ai_addrlen);
+    details.me = *gai;
+
     commSetCloseOnExec(sock);
+
     /* fdstat update */
     fd_open(sock, FD_SOCKET, "HTTP Request");
     fdd_table[sock].close_file = NULL;
@@ -1716,11 +1721,14 @@
     PROF_start(comm_udp_sendto);
     statCounter.syscalls.sock.sendtos++;
 
-    to_addr.GetAddrInfo(AI);
-
     debugs(50, 3, "comm_udp_sendto: Attempt to send UDP packet to " << to_addr <<
                   " using FD " << fd << " using Port " << comm_local_port(fd) );
 
+    /* BUG: something in the above macro appears to occasionally be setting AI to garbage. */
+    assert( NULL == AI );
+
+    to_addr.GetAddrInfo(AI);
+
     x = sendto(fd, buf, len, 0, AI->ai_addr, AI->ai_addrlen);
 
     to_addr.FreeAddrInfo(AI);
