--------------------- PatchSet 12284 Date: 2008/06/27 21:52:56 Author: hno Branch: SQUID_2_7 Tag: (none) Log: Plug a small "squid -k reconfigure" race in the new round-robin counter management The round-robin clear loop only got started on startup, not if the first round-robin peer was added by a "squid -k reconfigure". Members: src/cache_cf.c:1.480.2.11->1.480.2.12 src/neighbors.c:1.319.2.7->1.319.2.8 src/protos.h:1.547.2.9->1.547.2.10 Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid/squid/src/cache_cf.c,v retrieving revision 1.480.2.11 retrieving revision 1.480.2.12 diff -u -r1.480.2.11 -r1.480.2.12 --- squid/src/cache_cf.c 24 Jun 2008 23:14:18 -0000 1.480.2.11 +++ squid/src/cache_cf.c 27 Jun 2008 21:52:56 -0000 1.480.2.12 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.480.2.11 2008/06/24 23:14:18 hno Exp $ + * $Id: cache_cf.c,v 1.480.2.12 2008/06/27 21:52:56 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -1716,7 +1716,6 @@ parse_peer(peer ** head) { char *token = NULL; - void *arg = NULL; /* throwaway arg to make eventAdd happy */ peer *p; p = cbdataAlloc(peer); p->http_port = CACHE_HTTP_PORT; @@ -1916,9 +1915,7 @@ head = &(*head)->next; *head = p; Config.npeers++; - if (!reconfiguring && Config.npeers == 1) { - peerClearRRLoop(arg); - } + peerClearRRStart(); } static void Index: squid/src/neighbors.c =================================================================== RCS file: /cvsroot/squid/squid/src/neighbors.c,v retrieving revision 1.319.2.7 retrieving revision 1.319.2.8 diff -u -r1.319.2.7 -r1.319.2.8 --- squid/src/neighbors.c 24 Jun 2008 23:14:18 -0000 1.319.2.7 +++ squid/src/neighbors.c 27 Jun 2008 21:52:56 -0000 1.319.2.8 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.c,v 1.319.2.7 2008/06/24 23:14:18 hno Exp $ + * $Id: neighbors.c,v 1.319.2.8 2008/06/27 21:52:56 hno Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -281,13 +281,22 @@ } /* This gets called every 5 minutes to clear the round-robin counter. */ -void +static void peerClearRRLoop(void *data) { peerClearRR(); eventAdd("peerClearRR", peerClearRRLoop, data, 5 * 60.0, 0); } +void +peerClearRRStart(void) +{ + static int event_added = 0; + if (!event_added) { + peerClearRRLoop(NULL); + } +} + /* Actually clear the round-robin counter. */ void peerClearRR(void) Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid/squid/src/protos.h,v retrieving revision 1.547.2.9 retrieving revision 1.547.2.10 diff -u -r1.547.2.9 -r1.547.2.10 --- squid/src/protos.h 24 Jun 2008 23:14:18 -0000 1.547.2.9 +++ squid/src/protos.h 27 Jun 2008 21:52:56 -0000 1.547.2.10 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.547.2.9 2008/06/24 23:14:18 hno Exp $ + * $Id: protos.h,v 1.547.2.10 2008/06/27 21:52:56 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -688,7 +688,7 @@ extern peer *peerFindByNameAndPort(const char *, unsigned short); extern peer *getDefaultParent(request_t * request); extern peer *getRoundRobinParent(request_t * request); -EVH peerClearRRLoop; +extern void peerClearRRStart(void); extern void peerClearRR(void); extern peer *getAnyParent(request_t * request); extern lookup_t peerDigestLookup(peer * p, request_t * request);