Bug in beta 17, ipcache.c

From: Pete Bentley <pete@dont-contact.us>
Date: Fri, 21 Jun 1996 18:14:12 +0100

I have just tracked down what I *think* is the cause of some problems
we've been seeing under heavy loads, whereby proxy access to an entire
domain starts failing under squid. The symptoms are that entries end
up in the IP cache marked as 'pending' (because at some point there
were no free dnsserver children) but not in the pending queue, ie they
never get rescheduled via ipcache_dnsHandleRead()/dnsDequeue(), and
any further accesses to those domains appear to block as they simply
get added to the pending list. The patch below fixes one place where
this can occur if the queue of pending requests is bigger than the
number of free children (which will happen every time all the children
are simultaneously busy and there are two or more oending requests).
In case there are other places this can happen and that I missed, the
second part of the patch is simply a sanity check which will log when
this kind of problem occurs, most people will not want to apply that.

As far as I can see the first patch is clean...the bug is that
dnsDequeue has side effects which cause problems if the dequeued entry
is never dispatched. dnsGetFirstAvailable() has no such effects that I
can see.

Pete.
-----------------------------------------------------------------------------
*** ipcache.c 1996/06/13 16:57:57 1.1.1.4
--- ipcache.c 1996/06/21 17:05:58
***************
*** 765,771 ****
        COMM_SELECT_READ,
        (PF) ipcache_dnsHandleRead,
        dnsData);
! while ((i = dnsDequeue()) && (dnsData = dnsGetFirstAvailable()))
        dnsDispatch(dnsData, i);
      return 0;
  }
--- 765,771 ----
        COMM_SELECT_READ,
        (PF) ipcache_dnsHandleRead,
        dnsData);
! while ((dnsData = dnsGetFirstAvailable()) && (i = dnsDequeue()))
        dnsDispatch(dnsData, i);
      return 0;
  }
***************
*** 870,875 ****
--- 870,888 ----
        if (dnsQueueHead == NULL)
            dnsQueueTailP = &dnsQueueHead;
        safe_free(old);
+ }
+ /* Sanity check the cache */
+ if( i == NULL )
+ {
+ for (i = ipcache_GetFirst(); i; i = ipcache_GetNext())
+ {
+ if (i->status == IP_PENDING ) /* This can't happen */
+ {
+ debug(14,0, "IP Cache inconsistancy: %s still pending\n",
+ i->name);
+ }
+ }
+ i = NULL; /* To be sure... */
      }
      return i;
  }
Received on Fri Jun 21 1996 - 10:14:59 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:32:32 MST