From: robertc <> Date: Sun, 18 May 2003 06:34:49 +0000 (+0000) Subject: Summary: BUGFIX: Assert during FD exhaustion. X-Git-Tag: SQUID_3_0_PRE1~181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=601af4c6707825332de95b0af08b7998773e5346;p=thirdparty%2Fsquid.git Summary: BUGFIX: Assert during FD exhaustion. Keywords: During FD Exhaustion we put static (noncbdata) into the event queue. This patch allows non cbdata to be used without triggering a cbdata assert. --- diff --git a/src/event.cc b/src/event.cc index 20aef02b19..2b57e918a8 100644 --- a/src/event.cc +++ b/src/event.cc @@ -1,6 +1,6 @@ /* - * $Id: event.cc,v 1.36 2003/02/21 22:50:08 robertc Exp $ + * $Id: event.cc,v 1.37 2003/05/18 00:34:49 robertc Exp $ * * DEBUG: section 41 Event Processing * AUTHOR: Henrik Nordstrom @@ -48,6 +48,7 @@ struct ev_entry struct ev_entry *next; int weight; int id; + bool cbdata; }; static struct ev_entry *tasks = NULL; @@ -56,18 +57,19 @@ static int run_id = 0; static const char *last_event_ran = NULL; void -eventAdd(const char *name, EVH * func, void *arg, double when, int weight) +eventAdd(const char *name, EVH * func, void *arg, double when, int weight, bool cbdata) { struct ev_entry *event = (ev_entry *)memAllocate(MEM_EVENT); struct ev_entry **E; event->func = func; - event->arg = cbdataReference(arg); + event->arg = cbdata ? cbdataReference(arg) : arg; event->name = name; event->when = current_dtime + when; event->weight = weight; event->id = run_id; + event->cbdata = cbdata; debug(41, 7) ("eventAdd: Adding '%s', in %f seconds\n", name, when); /* Insert after the last event with the same or earlier time */ @@ -113,7 +115,8 @@ eventDelete(EVH * func, void *arg) *E = event->next; - cbdataReferenceDone(event->arg); + if (event->cbdata) + cbdataReferenceDone(event->arg); memFree(event, MEM_EVENT); @@ -159,7 +162,7 @@ eventRun(void) event->func = NULL; - if (cbdataReferenceValidDone(event->arg, &cbdata)) { + if (!event->cbdata || cbdataReferenceValidDone(event->arg, &cbdata)) { weight += event->weight; /* XXX assumes ->name is static memory! */ last_event_ran = event->name; @@ -209,7 +212,7 @@ eventDump(StoreEntry * sentry) while (e != NULL) { storeAppendPrintf(sentry, "%s\t%f seconds\t%d\t%s\n", e->name, e->when - current_dtime, e->weight, - e->arg ? cbdataReferenceValid(e->arg) ? "yes" : "no" : "N/A"); + (e->arg && e->cbdata) ? cbdataReferenceValid(e->arg) ? "yes" : "no" : "N/A"); e = e->next; } } @@ -222,7 +225,10 @@ eventFreeMemory(void) while ((event = tasks)) { tasks = event->next; - cbdataReferenceDone(event->arg); + + if (event->cbdata) + cbdataReferenceDone(event->arg); + memFree(event, MEM_EVENT); } diff --git a/src/protos.h b/src/protos.h index 9fff7822e1..e22190411d 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.477 2003/04/24 06:35:09 hno Exp $ + * $Id: protos.h,v 1.478 2003/05/18 00:34:50 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -229,7 +229,7 @@ SQUIDCEXTERN void idnsALookup(const char *, IDNSCB *, void *); SQUIDCEXTERN void idnsPTRLookup(const struct in_addr, IDNSCB *, void *); -SQUIDCEXTERN void eventAdd(const char *name, EVH * func, void *arg, double when, int); +SQUIDCEXTERN void eventAdd(const char *name, EVH * func, void *arg, double when, int, bool cbdata=true); SQUIDCEXTERN void eventAddIsh(const char *name, EVH * func, void *arg, double delta_ish, int); SQUIDCEXTERN void eventRun(void); SQUIDCEXTERN int eventNextTime(void);