If the 'arg' pointer becomes invalid, then the event is NOT run.
Events with NULL 'arg's are always run.
/*
- * $Id: cbdata.cc,v 1.19 1998/03/31 05:37:36 wessels Exp $
+ * $Id: cbdata.cc,v 1.20 1998/05/12 20:16:32 wessels Exp $
*
* DEBUG: section 45 Callback Data Registry
* AUTHOR: Duane Wessels
hash_remove_link(htable, (hash_link *) c);
cbdataCount--;
xfree(c);
+ if (mem_type == MEM_DONTFREE)
+ return;
debug(45, 3) ("cbdataReallyFree: Freeing %p\n", p);
if (mem_type == MEM_NONE)
xfree(p);
typedef enum {
MEM_NONE,
+ MEM_DONTFREE,
MEM_DISK_BUF,
MEM_STMEM_BUF,
MEM_4K_BUF,
/*
- * $Id: event.cc,v 1.13 1998/04/06 22:32:14 wessels Exp $
+ * $Id: event.cc,v 1.14 1998/05/12 20:16:33 wessels Exp $
*
* DEBUG: section 41 Event Processing
* AUTHOR: Henrik Nordstrom
event->arg = arg;
event->name = name;
event->when = squid_curtime + when;
+ if (NULL != arg)
+ cbdataLock(arg);
debug(41, 7) ("eventAdd: Adding '%s', in %d seconds\n", name, (int) when);
/* Insert after the last event with the same or earlier time */
for (E = &tasks; *E; E = &(*E)->next) {
if (event->arg != arg)
continue;
*E = event->next;
+ if (NULL != event->arg)
+ cbdataUnlock(event->arg);
xfree(event);
return;
}
return;
if (event->when > squid_curtime)
return;
- debug(41, 7) ("eventRun: Running '%s'\n", event->name);
func = event->func;
arg = event->arg;
event->func = NULL;
event->arg = NULL;
tasks = event->next;
safe_free(event);
+ if (NULL != arg) {
+ int valid = cbdataValid(arg);
+ cbdataUnlock(arg);
+ if (!valid)
+ return;
+ }
+ debug(41, 7) ("eventRun: Running '%s'\n", event->name);
func(arg);
}
/*
- * $Id: mem.cc,v 1.22 1998/04/24 07:09:37 wessels Exp $
+ * $Id: mem.cc,v 1.23 1998/05/12 20:16:34 wessels Exp $
*
* DEBUG: section 13 High Level Memory Pool Management
* AUTHOR: Harvest Derived
memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0);
/* test that all entries are initialized */
for (t = MEM_NONE + 1; t < MEM_MAX; t++) {
+ if (MEM_DONTFREE == t)
+ continue;
/*
* If you hit this assertion, then you forgot to add a
* memDataInit() line for type 't' above.
/*
- * $Id: store_digest.cc,v 1.13 1998/05/05 23:02:50 wessels Exp $
+ * $Id: store_digest.cc,v 1.14 1998/05/12 20:16:34 wessels Exp $
*
* DEBUG: section 71 Store Digest Manager
* AUTHOR: Alex Rousskov
EBIT_SET(flags, REQ_CACHABLE);
sd_state.rewrite_lock = e = storeCreateEntry(url, url, flags, METHOD_GET);
assert(sd_state.rewrite_lock);
+ cbdataAdd(sd_state.rewrite_lock, MEM_DONTFREE);
debug(71, 3) ("storeDigestRewrite: url: %s key: %s\n", url, storeKeyText(e->key));
e->mem_obj->request = requestLink(urlParse(METHOD_GET, url));
/* wait for rebuild (if any) to finish */
requestUnlink(e->mem_obj->request);
e->mem_obj->request = NULL;
storeUnlockObject(e);
+ /*
+ * note, it won't really get free()'d here because we used
+ * MEM_DONTFREE in the call to cbdataAdd().
+ */
+ cbdataFree(sd_state.rewrite_lock);
sd_state.rewrite_lock = e = NULL;
sd_state.rewrite_count++;
eventAdd("storeDigestRewriteStart", storeDigestRewriteStart, NULL, StoreDigestRewritePeriod);