--------------------- PatchSet 5559 Date: 2007/08/29 11:52:37 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Boost internal resolver CNAME lookup with a waiting state counter. Adds cname_wait to each ipcache entry. Counter indicates number of CNAME callbacks which have been initiated. ALL must be completed before entry can safely be added to cache and parent callback resumed. Members: src/ipcache.cc:1.9.2.43->1.9.2.44 Index: squid3/src/ipcache.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ipcache.cc,v retrieving revision 1.9.2.43 retrieving revision 1.9.2.44 diff -u -r1.9.2.43 -r1.9.2.44 --- squid3/src/ipcache.cc 26 Aug 2007 03:43:54 -0000 1.9.2.43 +++ squid3/src/ipcache.cc 29 Aug 2007 11:52:37 -0000 1.9.2.44 @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.9.2.43 2007/08/26 03:43:54 amosjeffries Exp $ + * $Id: ipcache.cc,v 1.9.2.44 2007/08/29 11:52:37 amosjeffries Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -57,6 +57,7 @@ struct timeval request_time; dlink_node lru; unsigned short locks; + unsigned short cname_wait; struct { @@ -240,6 +241,9 @@ { hash_link *e = (hash_link *)hash_lookup(ip_table, i->hash.key); + /* INET6 : should NOT be adding this entry until all CNAME have been received. */ + assert(i->cname_wait == 0); + if (NULL != e) { /* avoid colission */ ipcache_entry *q = (ipcache_entry *) e; @@ -393,7 +397,6 @@ int j = 0; int na = 0; int ttl = 0; - bool cnames = false; const char *name = (const char *)i->hash.key; i->expires = squid_curtime + Config.negativeDnsTtl; i->flags.negcached = 1; @@ -453,13 +456,13 @@ /* keep going on this, but flag the fact that we need to wait for a CNAME lookup to finish */ debugs(14, 5, "ipcacheParse: CNAME " << answers[k].rdata << " has no IPs! Recursing."); ipcache_nbgethostbyname(answers[k].rdata, ipcacheHandleCnameRecurse, new generic_cbdata(i) ); - cnames = true; + i->cname_wait++; } continue; } } - if(na == 0 && cnames ) { + if(na == 0 && i->cname_wait >0 ) { /* don't set any error message (yet). Allow recursion to do its work first. */ return 0; } @@ -540,7 +543,7 @@ /* SPECIAL CASE: may get here IFF CNAME received with Additional records */ /* reurn 0/'wait for further details' value. */ /* NP: 'No DNS Results' is a return -1 +msg */ - if(cnames) + if(i->cname_wait) return 0; else return i->addrs.count; @@ -816,6 +819,11 @@ gcb->unwrap(&i); assert(i != NULL); + // make sure we are actualy waitign for a CNAME callback to be run. + assert(i->cname_wait > 0); + // count this event. its being handled. + i->cname_wait--; + pname = (char*)i->hash.key; assert(pname != NULL); @@ -843,7 +851,7 @@ if( pcount > 0) { /* IFF the parent initial lookup was given Additional records with A */ - /* we need to merge the two lists (dropping duplicates) */ + /* FIXME INET6 : we need to merge the two lists dropping duplicates */ debugs(14, 5, "ipcacheHandleCnameRecurse: Add " << pcount << " IPs from Initial Lookup."); @@ -900,8 +908,11 @@ } /* finish the lookup we were doing on parent when we got side-tracked for CNAME loop */ - ipcacheAddEntry(i); - ipcacheCallback(i); + if(i->cname_wait == 0) { + ipcacheAddEntry(i); + ipcacheCallback(i); + } + // else still more CNAME to be found. } void