--------------------- PatchSet 4776 Date: 2007/06/22 06:09:45 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Fix thinking error. A NULL set IPAddress was one of the valid uses as a basic type. Handle it nicely now. Members: lib/IPAddress.cc:1.1.2.48->1.1.2.49 src/fd.cc:1.10.4.4->1.10.4.5 src/fde.cc:1.3.10.2->1.3.10.3 src/fde.h:1.7.8.5->1.7.8.6 Index: squid3/lib/IPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/Attic/IPAddress.cc,v retrieving revision 1.1.2.48 retrieving revision 1.1.2.49 diff -u -r1.1.2.48 -r1.1.2.49 --- squid3/lib/IPAddress.cc 21 Jun 2007 12:29:39 -0000 1.1.2.48 +++ squid3/lib/IPAddress.cc 22 Jun 2007 06:09:45 -0000 1.1.2.49 @@ -1,6 +1,6 @@ /* - * $Id: IPAddress.cc,v 1.1.2.48 2007/06/21 12:29:39 amosjeffries Exp $ + * $Id: IPAddress.cc,v 1.1.2.49 2007/06/22 06:09:45 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -95,19 +95,7 @@ IPAddress::IPAddress() { - memset(this,0,sizeof(IPAddress)); -#if USE_IPV6 - - m_Type = IPv64; - - assert( m_Type & IPv6 ); - assert( m_Type & IPv4 ); -#else - - m_Type = IPv4; - - assert( m_Type & IPv4 ); -#endif + SetEmpty(); } IPAddress::~IPAddress() @@ -275,16 +263,21 @@ #endif } -/// NOTE: completely empties the IPAddres structure. Adress, Port, Type, everything. +/// NOTE: completely empties the IPAddres structure. Address, Port, Type, everything. void IPAddress::SetEmpty() { memset(&m_SocketAddr, 0, sizeof(m_SocketAddr) ); #if USE_IPV6 m_Type = IPv64; + + assert( m_Type & IPv6 ); + assert( m_Type & IPv4 ); #else - m_Type=IPv4; + m_Type = IPv4; + + assert( m_Type & IPv4 ); #endif } @@ -874,7 +867,13 @@ return NULL; } - memset(buf,0,blen); + /* some external code may have blindly memset a parent. */ + /* thats okay, our default can be set anytime */ + if(m_Type == None) { + SetEmpty(); + } + + memset(buf,0,blen); // clear buffer before write if( (force & IPv64) && !(force & m_Type) ) { if( IsIPv6() ) @@ -902,7 +901,7 @@ debugs(14,0,"WARNING: Corrupt IP Address details found!"); fprintf(stderr,"WARNING: Corrupt IP Address details found!"); memcpy(buf,"dead:beef::",12); -// assert(false); + assert(false); } return buf; Index: squid3/src/fd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fd.cc,v retrieving revision 1.10.4.4 retrieving revision 1.10.4.5 diff -u -r1.10.4.4 -r1.10.4.5 --- squid3/src/fd.cc 3 Jun 2007 12:14:47 -0000 1.10.4.4 +++ squid3/src/fd.cc 22 Jun 2007 06:09:45 -0000 1.10.4.5 @@ -1,6 +1,6 @@ /* - * $Id: fd.cc,v 1.10.4.4 2007/06/03 12:14:47 amosjeffries Exp $ + * $Id: fd.cc,v 1.10.4.5 2007/06/22 06:09:45 amosjeffries Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -103,7 +103,7 @@ F->flags.open = 0; fdUpdateBiggest(fd, 0); Number_FD--; - memset(F, '\0', sizeof(fde)); + F->clear(); F->timeout = 0; } Index: squid3/src/fde.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fde.cc,v retrieving revision 1.3.10.2 retrieving revision 1.3.10.3 diff -u -r1.3.10.2 -r1.3.10.3 --- squid3/src/fde.cc 25 Apr 2007 13:05:11 -0000 1.3.10.2 +++ squid3/src/fde.cc 22 Jun 2007 06:09:45 -0000 1.3.10.3 @@ -1,6 +1,6 @@ /* - * $Id: fde.cc,v 1.3.10.2 2007/04/25 13:05:11 amosjeffries Exp $ + * $Id: fde.cc,v 1.3.10.3 2007/06/22 06:09:45 amosjeffries Exp $ * * DEBUG: none FDE * AUTHOR: Robert Collins @@ -39,6 +39,18 @@ #include "Store.h" #include "comm.h" +fde::fde() +{ + clear(); +} + +void +fde::clear() +{ + memset(this, 0, sizeof(fde)); + local_addr.SetEmpty(); // IPAddress likes to be setup nicely. +} + bool fde::readPending(int fdNumber) { Index: squid3/src/fde.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fde.h,v retrieving revision 1.7.8.5 retrieving revision 1.7.8.6 diff -u -r1.7.8.5 -r1.7.8.6 --- squid3/src/fde.h 3 Jun 2007 12:14:47 -0000 1.7.8.5 +++ squid3/src/fde.h 22 Jun 2007 06:09:45 -0000 1.7.8.6 @@ -1,6 +1,6 @@ /* - * $Id: fde.h,v 1.7.8.5 2007/06/03 12:14:47 amosjeffries Exp $ + * $Id: fde.h,v 1.7.8.6 2007/06/22 06:09:45 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,6 +43,9 @@ { public: + /** Clear the fde class properly back to NULL equivalent. */ + void clear(); + /* NOTE: memset is used on fdes today. 20030715 RBC */ static void DumpStats (StoreEntry *);