<article>
<title>Squid Programmers Guide</title>
<author>Duane Wessels, Squid Developers
-<date>$Id: prog-guide.sgml,v 1.35 2001/01/31 22:16:36 hno Exp $</date>
+<date>$Id: prog-guide.sgml,v 1.36 2001/03/03 10:39:29 hno Exp $</date>
<abstract>
Squid is a WWW Cache application developed by the National Laboratory
<verb>
type_of_data callback_data;
...
- callback_data = CBDATA_ALLOC(type_of_data, free_handler);
+ callback_data = cbdataAlloc(type_of_data);
...
cbdataLock(callback_data);
fooOperationStart(bar, callback_func, callback_data);
With this scheme, nothing bad happens if <tt/cbdataFree/ gets called
before <tt/cbdataUnlock/:
<verb>
- callback_data = CBDATA_ALLOC(...);
+ callback_data = cbdataAlloc(...);
...
cbdataLock(callback_data);
fooOperationStart(bar, callback_func, callback_data);
<P>
To add new module specific data types to the allocator one uses the
macros CBDATA_TYPE and CBDATA_INIT_TYPE. These creates a local cbdata
- definition (file or block scope). Any CBDATA_ALLOC calls must be made
+ definition (file or block scope). Any cbdataAlloc calls must be made
within this scope. However, cbdataFree might be called from anywhere.
<verb>
* (can be called multiple times with only a minimal overhead)
*/
CBDATA_INIT_TYPE(type_of_data);
+ /* Or if a free function is associated with the data type */
+ CBDATA_INIT_TYPE_FREECB(type_of_data, free_function);
</verb>
<P>
extern CBDATA_GLOBAL_TYPE(type_of_data); /* CBDATA_UNDEF */
</verb>
- <P>
- TODO: Restructure the free function so there is one free function
- associated with the whole cbdata type rather than per allocation.
-
<!-- %%%% Chapter : CACHE MANAGER %%%% -->
<sect>Cache Manager
/*
- * $Id: acl.cc,v 1.249 2001/02/23 20:59:50 hno Exp $
+ * $Id: acl.cc,v 1.250 2001/03/03 10:39:30 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
debug(28, 0) ("aclParseAccessLine: missing 'allow' or 'deny'.\n");
return;
}
- A = CBDATA_ALLOC(acl_access, NULL);
+ A = cbdataAlloc(acl_access);
if (!strcmp(t, "allow"))
A->allow = 1;
{
int i;
aclCheck_t *checklist;
- checklist = CBDATA_ALLOC(aclCheck_t, NULL);
+ checklist = cbdataAlloc(aclCheck_t);
checklist->access_list = A;
/*
* aclCheck() makes sure checklist->access_list is a valid
/*
- * $Id: asn.cc,v 1.70 2001/02/07 19:04:08 hno Exp $
+ * $Id: asn.cc,v 1.71 2001/03/03 10:39:30 hno Exp $
*
* DEBUG: section 53 AS Number handling
* AUTHOR: Duane Wessels, Kostas Anagnostakis
StoreEntry *e;
request_t *req;
ASState *asState;
- asState = CBDATA_ALLOC(ASState, NULL);
+ asState = cbdataAlloc(ASState);
debug(53, 3) ("asnCacheStart: AS %d\n", as);
snprintf(asres, 4096, "whois://%s/!gAS%d", Config.as_whois_server, as);
asState->as_number = as;
/*
- * $Id: auth_basic.cc,v 1.6 2001/02/07 18:56:53 hno Exp $
+ * $Id: auth_basic.cc,v 1.7 2001/03/03 10:39:36 hno Exp $
*
* DEBUG: section 29 Authenticator
* AUTHOR: Duane Wessels
authBasicDataFree(basic_data * basic_auth)
{
}
+
#endif
static auth_user_t *
cbdataLock(data);
return;
} else {
- r = CBDATA_ALLOC(authenticateStateData, NULL);
+ r = cbdataAlloc(authenticateStateData);
r->handler = handler;
cbdataLock(data);
r->data = data;
/*
- * $Id: auth_digest.cc,v 1.1 2001/01/31 22:16:41 hno Exp $
+ * $Id: auth_digest.cc,v 1.2 2001/03/03 10:39:36 hno Exp $
*
* DEBUG: section 29 Authenticator
* AUTHOR: Robert Collins
}
}
-void
+void
authenticateDigestNonceSetup()
{
if (!digest_nonce_pool)
}
}
-void
+void
authenticateDigestNonceShutdown()
{
/*
debug(29, 2) ("authenticateDigestNonceShutdown: Nonce cache shutdown\n");
}
-void
+void
authenticateDigestNonceReconfigure()
{
}
return;
}
-int
+int
authenticateDigestDirection(auth_user_request_t * auth_user_request)
{
digest_request_h *digest_request;
handler(data, NULL);
return;
}
- r = CBDATA_ALLOC(authenticateStateData, NULL);
+ r = cbdataAlloc(authenticateStateData);
r->handler = handler;
cbdataLock(data);
r->data = data;
/*
- * $Id: auth_ntlm.cc,v 1.6 2001/01/31 22:16:43 hno Exp $
+ * $Id: auth_ntlm.cc,v 1.7 2001/03/03 10:39:36 hno Exp $
*
* DEBUG: section 29 NTLM Authenticator
* AUTHOR: Robert Collins
return;
}
#ifdef NTLMHELPPROTOCOLV2
- r = CBDATA_ALLOC(authenticateStateData, NULL);
+ r = cbdataAlloc(authenticateStateData);
r->handler = handler;
cbdataLock(data);
r->data = data;
debug(29, 9) ("authenticateNTLMStart: helper '%d' assigned\n", server);
/* valid challenge? */
if ((server == NULL) || !authenticateNTLMValidChallenge(helperstate)) {
- r = CBDATA_ALLOC(authenticateStateData, NULL);
+ r = cbdataAlloc(authenticateStateData);
r->handler = handler;
cbdataLock(data);
r->data = data;
break;
case AUTHENTICATE_STATE_RESPONSE:
- r = CBDATA_ALLOC(authenticateStateData, NULL);
+ r = cbdataAlloc(authenticateStateData);
r->handler = handler;
cbdataLock(data);
r->data = data;
/*
- * $Id: cache_cf.cc,v 1.377 2001/02/23 20:59:50 hno Exp $
+ * $Id: cache_cf.cc,v 1.378 2001/03/03 10:39:30 hno Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
if (Config.Wais.relayHost) {
if (Config.Wais.peer)
cbdataFree(Config.Wais.peer);
- Config.Wais.peer = CBDATA_ALLOC(peer, peerDestroy);
+ Config.Wais.peer = cbdataAlloc(peer);
Config.Wais.peer->host = xstrdup(Config.Wais.relayHost);
Config.Wais.peer->http_port = Config.Wais.relayPort;
}
int i;
for (i = 0; i < HDR_ENUM_END; i++) {
if (header[i].access_list != NULL) {
- storeAppendPrintf(entry, "%s ",name);
+ storeAppendPrintf(entry, "%s ", name);
dump_acl_access(entry, httpHeaderNameById(i),
header[i].access_list);
}
if (id != HDR_ENUM_END) {
parse_acl_access(&header[id].access_list);
} else {
- char *next_string = t + strlen(t) -1;
+ char *next_string = t + strlen(t) - 1;
*next_string = 'A';
- *(next_string+1) = ' ';
+ *(next_string + 1) = ' ';
for (i = 0; i < HDR_ENUM_END; i++) {
char *new_string = xstrdup(next_string);
strtok(new_string, w_space);
char *token = NULL;
peer *p;
int i;
- p = CBDATA_ALLOC(peer, peerDestroy);
+ p = cbdataAlloc(peer);
p->http_port = CACHE_HTTP_PORT;
p->icp.port = CACHE_ICP_PORT;
p->weight = 1;
/*
- * $Id: cbdata.cc,v 1.37 2001/01/31 21:46:04 hno Exp $
+ * $Id: cbdata.cc,v 1.38 2001/03/03 10:39:31 hno Exp $
*
* DEBUG: section 45 Callback Data Registry
* ORIGINAL AUTHOR: Duane Wessels
typedef struct _cbdata {
int valid;
int locks;
- CBDUNL *free_func;
- int type; /* move to CBDATA_DEBUG with type argument to cbdataFree */
+ int type;
#if CBDATA_DEBUG
const char *file;
int line;
static OBJH cbdataDump;
-static MemPool **cbdata_memory_pool = NULL;
+struct {
+ MemPool *pool;
+ FREE *free_func;
+} *cbdata_index = NULL;
int cbdata_types = 0;
#define OFFSET_OF(type, member) ((int)(char *)&((type *)0L)->member)
void
-cbdataInitType(cbdata_type type, char *name, int size)
+cbdataInitType(cbdata_type type, char *name, int size, FREE * free_func)
{
char *label;
if (type >= cbdata_types) {
- cbdata_memory_pool = xrealloc(cbdata_memory_pool, (type + 1) * sizeof(*cbdata_memory_pool));
- memset(&cbdata_memory_pool[cbdata_types], 0,
- (type + 1 - cbdata_types) * sizeof(*cbdata_memory_pool));
+ cbdata_index = xrealloc(cbdata_index, (type + 1) * sizeof(*cbdata_index));
+ memset(&cbdata_index[cbdata_types], 0,
+ (type + 1 - cbdata_types) * sizeof(*cbdata_index));
cbdata_types = type + 1;
}
- if (cbdata_memory_pool[type])
+ if (cbdata_index[type].pool)
return;
label = xmalloc(strlen(name) + 20);
snprintf(label, strlen(name) + 20, "cbdata %s (%d)", name, (int) type);
assert(OFFSET_OF(cbdata, data) == (sizeof(cbdata) - sizeof(((cbdata *) NULL)->data)));
- cbdata_memory_pool[type] = memPoolCreate(label, size + OFFSET_OF(cbdata, data));
+ cbdata_index[type].pool = memPoolCreate(label, size + OFFSET_OF(cbdata, data));
+ cbdata_index[type].free_func = free_func;
}
cbdata_type
-cbdataAddType(cbdata_type type, char *name, int size)
+cbdataAddType(cbdata_type type, char *name, int size, FREE * free_func)
{
if (type)
return type;
type = cbdata_types;
- cbdataInitType(type, name, size);
+ cbdataInitType(type, name, size, free_func);
return type;
}
cachemgrRegister("cbdata",
"Callback Data Registry Contents",
cbdataDump, 0, 1);
-#define CREATE_CBDATA(type) cbdataInitType(CBDATA_##type, #type, sizeof(type))
+#define CREATE_CBDATA(type) cbdataInitType(CBDATA_##type, #type, sizeof(type), NULL)
+#define CREATE_CBDATA_FREE(type, free_func) cbdataInitType(CBDATA_##type, #type, sizeof(type), free_func)
CREATE_CBDATA(acl_access);
CREATE_CBDATA(aclCheck_t);
CREATE_CBDATA(clientHttpRequest);
CREATE_CBDATA(statefulhelper);
CREATE_CBDATA(helper_stateful_server);
CREATE_CBDATA(HttpStateData);
- CREATE_CBDATA(peer);
+ CREATE_CBDATA_FREE(peer, peerDestroy);
CREATE_CBDATA(ps_state);
CREATE_CBDATA(RemovalPolicy);
CREATE_CBDATA(RemovalPolicyWalker);
CREATE_CBDATA(RemovalPurgeWalker);
CREATE_CBDATA(store_client);
- CREATE_CBDATA(storeIOState);
}
void *
#if CBDATA_DEBUG
-cbdataInternalAllocDbg(cbdata_type type, CBDUNL * free_func, const char *file, int line)
+cbdataInternalAllocDbg(cbdata_type type, const char *file, int line)
#else
-cbdataInternalAlloc(cbdata_type type, CBDUNL * free_func)
+cbdataInternalAlloc(cbdata_type type)
#endif
{
cbdata *p;
assert(type > 0 && type < cbdata_types);
- p = memPoolAlloc(cbdata_memory_pool[type]);
+ p = memPoolAlloc(cbdata_index[type].pool);
p->type = type;
- p->free_func = free_func;
p->valid = 1;
p->locks = 0;
#if CBDATA_DEBUG
}
void
-cbdataFree(void *p)
+cbdataInternalFree(void *p)
{
cbdata *c;
+ FREE *free_func;
+ if (!p)
+ return;
debug(45, 3) ("cbdataFree: %p\n", p);
- assert(p);
c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data));
assert(c->y == c);
c->valid = 0;
}
cbdataCount--;
debug(45, 3) ("cbdataFree: Freeing %p\n", p);
- if (c->free_func)
- c->free_func((void *) p);
- memPoolFree(cbdata_memory_pool[c->type], c);
+ free_func = cbdata_index[c->type].free_func;
+ if (free_func)
+ free_func((void *) p);
+ memPoolFree(cbdata_index[c->type].pool, c);
+}
+
+int
+cbdataLocked(const void *p)
+{
+ cbdata *c;
+ assert(p);
+ c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data));
+ assert(c->y == c);
+ debug(45, 3) ("cbdataLocked: %p = %d\n", p, c->locks);
+ assert(c != NULL);
+ return c->locks;
}
void
#endif
{
cbdata *c;
+ FREE *free_func;
if (p == NULL)
return;
c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data));
return;
cbdataCount--;
debug(45, 3) ("cbdataUnlock: Freeing %p\n", p);
- if (c->free_func)
- c->free_func((void *) p);
- memPoolFree(cbdata_memory_pool[c->type], c);
+ free_func = cbdata_index[c->type].free_func;
+ if (free_func)
+ free_func((void *) p);
+ memPoolFree(cbdata_index[c->type].pool, c);
}
int
/*
- * $Id: client_side.cc,v 1.530 2001/03/01 23:02:31 wessels Exp $
+ * $Id: client_side.cc,v 1.531 2001/03/03 10:39:31 hno Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
parseHttpRequestAbort(ConnStateData * conn, const char *uri)
{
clientHttpRequest *http;
- http = CBDATA_ALLOC(clientHttpRequest, NULL);
+ http = cbdataAlloc(clientHttpRequest);
http->conn = conn;
http->start = current_time;
http->req_sz = conn->in.offset;
assert(prefix_sz <= conn->in.offset);
/* Ok, all headers are received */
- http = CBDATA_ALLOC(clientHttpRequest, NULL);
+ http = cbdataAlloc(clientHttpRequest);
http->http_ver = http_ver;
http->conn = conn;
http->start = current_time;
break;
}
debug(33, 4) ("httpAccept: FD %d: accepted\n", fd);
- connState = CBDATA_ALLOC(ConnStateData, NULL);
+ connState = cbdataAlloc(ConnStateData);
connState->peer = peer;
connState->log_addr = peer.sin_addr;
connState->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr;
/*
- * $Id: comm.cc,v 1.316 2001/02/23 19:42:36 wessels Exp $
+ * $Id: comm.cc,v 1.317 2001/03/03 10:39:31 hno Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
{
ConnectStateData *cs;
debug(5, 3) ("commConnectStart: FD %d, %s:%d\n", fd, host, (int) port);
- cs = CBDATA_ALLOC(ConnectStateData, NULL);
+ cs = cbdataAlloc(ConnectStateData);
cs->fd = fd;
cs->host = xstrdup(host);
cs->port = port;
/*
- * $Id: defines.h,v 1.89 2001/01/12 00:37:16 wessels Exp $
+ * $Id: defines.h,v 1.90 2001/03/03 10:39:31 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
#endif
/* cbdata macros */
-#define CBDATA_ALLOC(type, unl) ((type *)cbdataInternalAlloc(CBDATA_##type, unl))
+#define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type))
+#define cbdataFree(var) (var = (cbdataInternalFree(var), NULL))
#define CBDATA_TYPE(type) static cbdata_type CBDATA_##type = 0
#define CBDATA_GLOBAL_TYPE(type) cbdata_type CBDATA_##type
-#define CBDATA_INIT_TYPE(type) (CBDATA_##type ? 0 : (CBDATA_##type = cbdataAddType(CBDATA_##type, #type, sizeof(type))))
+#define CBDATA_INIT_TYPE(type) (CBDATA_##type ? 0 : (CBDATA_##type = cbdataAddType(CBDATA_##type, #type, sizeof(type), NULL)))
+#define CBDATA_INIT_TYPE_FREECB(type, free_func) (CBDATA_##type ? 0 : (CBDATA_##type = cbdataAddType(CBDATA_##type, #type, sizeof(type), free_func)))
#ifndef O_TEXT
#define O_TEXT 0
/*
- * $Id: enums.h,v 1.187 2001/02/18 11:16:51 hno Exp $
+ * $Id: enums.h,v 1.188 2001/03/03 10:39:31 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
CBDATA_RemovalPolicyWalker,
CBDATA_RemovalPurgeWalker,
CBDATA_store_client,
- CBDATA_storeIOState,
CBDATA_FIRST_CUSTOM_TYPE = 1000
} cbdata_type;
/*
- * $Id: errorpage.cc,v 1.162 2001/01/12 00:37:17 wessels Exp $
+ * $Id: errorpage.cc,v 1.163 2001/03/03 10:39:31 hno Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
errorCon(err_type type, http_status status)
{
ErrorState *err;
- err = CBDATA_ALLOC(ErrorState, NULL);
+ err = cbdataAlloc(ErrorState);
err->page_id = type; /* has to be reset manually if needed */
err->type = type;
err->http_status = status;
/*
- * $Id: forward.cc,v 1.80 2001/01/12 00:37:17 wessels Exp $
+ * $Id: forward.cc,v 1.81 2001/03/03 10:39:31 hno Exp $
*
* DEBUG: section 17 Request Forwarding
* AUTHOR: Duane Wessels
default:
break;
}
- fwdState = CBDATA_ALLOC(FwdState, NULL);
+ fwdState = cbdataAlloc(FwdState);
fwdState->entry = e;
fwdState->client_fd = fd;
fwdState->server_fd = -1;
/*
- * $Id: fqdncache.cc,v 1.147 2001/02/23 20:59:51 hno Exp $
+ * $Id: fqdncache.cc,v 1.148 2001/03/03 10:39:31 hno Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
f->handlerData = handlerData;
cbdataLock(handlerData);
f->request_time = current_time;
- c = CBDATA_ALLOC(generic_cbdata, NULL);
+ c = cbdataAlloc(generic_cbdata);
c->data = f;
#if USE_DNSSERVERS
dnsSubmit(hashKeyStr(&f->hash), fqdncacheHandleReply, c);
/*
- * $Id: store_dir_aufs.cc,v 1.31 2001/02/19 23:10:06 hno Exp $
+ * $Id: store_dir_aufs.cc,v 1.32 2001/03/03 10:39:37 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
FILE *fp;
EVH *func = NULL;
CBDATA_INIT_TYPE(RebuildState);
- rb = CBDATA_ALLOC(RebuildState, NULL);
+ rb = cbdataAlloc(RebuildState);
rb->sd = sd;
rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
/*
static int storeAufsKickWriteQueue(storeIOState * sio);
static CBDUNL storeAufsIOFreeEntry;
+CBDATA_TYPE(storeIOState);
+
/* === PUBLIC =========================================================== */
/* open for reading */
return NULL;
}
#endif
- sio = CBDATA_ALLOC(storeIOState, storeAufsIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeAufsIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
sio->fsstate = memPoolAlloc(aio_state_pool);
((aiostate_t *) (sio->fsstate))->fd = -1;
((aiostate_t *) (sio->fsstate))->flags.opening = 1;
return NULL;
}
#endif
- sio = CBDATA_ALLOC(storeIOState, storeAufsIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeAufsIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
sio->fsstate = memPoolAlloc(aio_state_pool);
((aiostate_t *) (sio->fsstate))->fd = -1;
((aiostate_t *) (sio->fsstate))->flags.opening = 1;
/*
- * $Id: store_dir_coss.cc,v 1.19 2001/02/10 16:40:41 hno Exp $
+ * $Id: store_dir_coss.cc,v 1.20 2001/03/03 10:39:37 hno Exp $
*
* DEBUG: section 81 Store COSS Directory Routines
* AUTHOR: Eric Stern
FILE *fp;
EVH *func = NULL;
CBDATA_INIT_TYPE(RebuildState);
- rb = CBDATA_ALLOC(RebuildState, NULL);
+ rb = cbdataAlloc(RebuildState);
rb->sd = sd;
rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
func = storeCossRebuildFromSwapLog;
/*
- * $Id: store_io_coss.cc,v 1.7 2001/01/12 00:37:33 wessels Exp $
+ * $Id: store_io_coss.cc,v 1.8 2001/03/03 10:39:37 hno Exp $
*
* DEBUG: section 81 Storage Manager COSS Interface
* AUTHOR: Eric Stern
static CBDUNL storeCossIOFreeEntry;
static CBDUNL storeCossMembufFree;
+CBDATA_TYPE(storeIOState);
+
/* === PUBLIC =========================================================== */
/*
CossState *cstate;
storeIOState *sio;
- sio = CBDATA_ALLOC(storeIOState, storeCossIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeCossIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
cstate = memPoolAlloc(coss_state_pool);
sio->fsstate = cstate;
sio->offset = 0;
debug(81, 3) ("storeCossOpen: offset %d\n", f);
- sio = CBDATA_ALLOC(storeIOState, storeCossIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeCossIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
cstate = memPoolAlloc(coss_state_pool);
sio->fsstate = cstate;
int numreleased = 0;
CossInfo *cs = (CossInfo *) SD->fsdata;
- CBDATA_INIT_TYPE(CossMemBuf);
- newmb = CBDATA_ALLOC(CossMemBuf, storeCossMembufFree);
+ CBDATA_INIT_TYPE_FREECB(CossMemBuf, storeCossMembufFree);
+ newmb = cbdataAlloc(CossMemBuf);
newmb->diskstart = start;
debug(81, 3) ("storeCossCreateMemBuf: creating new membuf at %d\n", newmb->diskstart);
newmb->diskend = newmb->diskstart + COSS_MEMBUF_SZ - 1;
/*
- * $Id: store_dir_diskd.cc,v 1.44 2001/03/01 22:28:22 hno Exp $
+ * $Id: store_dir_diskd.cc,v 1.45 2001/03/03 10:39:38 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
FILE *fp;
EVH *func = NULL;
CBDATA_INIT_TYPE(RebuildState);
- rb = CBDATA_ALLOC(RebuildState, NULL);
+ rb = cbdataAlloc(RebuildState);
rb->sd = sd;
rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
/*
storeAppendPrintf(sentry, "Pending operations: %d\n", diskdinfo->away);
}
-static void
+static void
storeDiskdDirParseQ1(SwapDir * sd, const char *name, const char *value, int reconfiguring)
{
diskdinfo_t *diskdinfo = sd->fsdata;
debug(3, 1) ("cache_dir '%s' new Q1 value '%d'\n", diskdinfo->magic1);
}
-static void
+static void
storeDiskdDirParseQ2(SwapDir * sd, const char *name, const char *value, int reconfiguring)
{
diskdinfo_t *diskdinfo = sd->fsdata;
/*
- * $Id: store_io_diskd.cc,v 1.20 2001/01/12 00:37:33 wessels Exp $
+ * $Id: store_io_diskd.cc,v 1.21 2001/03/03 10:39:38 hno Exp $
*
* DEBUG: section 81 Squid-side DISKD I/O functions.
* AUTHOR: Duane Wessels
static void storeDiskdIOCallback(storeIOState * sio, int errflag);
static CBDUNL storeDiskdIOFreeEntry;
+CBDATA_TYPE(storeIOState);
+
/* === PUBLIC =========================================================== */
storeIOState *
diskd_stats.open_fail_queue_len++;
return NULL;
}
- sio = CBDATA_ALLOC(storeIOState, storeDiskdIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeDiskdIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
sio->fsstate = diskdstate = memPoolAlloc(diskd_state_pool);
sio->swap_filen = f;
f = storeDiskdDirMapBitAllocate(SD);
debug(81, 3) ("storeDiskdCreate: fileno %08X\n", f);
- sio = CBDATA_ALLOC(storeIOState, storeDiskdIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeDiskdIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
sio->fsstate = diskdstate = memPoolAlloc(diskd_state_pool);
sio->swap_filen = f;
/*
- * $Id: store_dir_ufs.cc,v 1.30 2001/02/19 23:10:07 hno Exp $
+ * $Id: store_dir_ufs.cc,v 1.31 2001/03/03 10:39:39 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
FILE *fp;
EVH *func = NULL;
CBDATA_INIT_TYPE(RebuildState);
- rb = CBDATA_ALLOC(RebuildState, NULL);
+ rb = cbdataAlloc(RebuildState);
rb->sd = sd;
rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
/*
/*
- * $Id: store_io_ufs.cc,v 1.6 2001/01/12 00:37:35 wessels Exp $
+ * $Id: store_io_ufs.cc,v 1.7 2001/03/03 10:39:39 hno Exp $
*
* DEBUG: section 79 Storage Manager UFS Interface
* AUTHOR: Duane Wessels
static void storeUfsIOCallback(storeIOState * sio, int errflag);
static CBDUNL storeUfsIOFreeEntry;
+CBDATA_TYPE(storeIOState);
+
/* === PUBLIC =========================================================== */
storeIOState *
return NULL;
}
debug(79, 3) ("storeUfsOpen: opened FD %d\n", fd);
- sio = CBDATA_ALLOC(storeIOState, storeUfsIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeUfsIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
sio->fsstate = memPoolAlloc(ufs_state_pool);
sio->swap_filen = f;
return NULL;
}
debug(79, 3) ("storeUfsCreate: opened FD %d\n", fd);
- sio = CBDATA_ALLOC(storeIOState, storeUfsIOFreeEntry);
+ CBDATA_INIT_TYPE_FREECB(storeIOState, storeUfsIOFreeEntry);
+ sio = cbdataAlloc(storeIOState);
sio->fsstate = memPoolAlloc(ufs_state_pool);
sio->swap_filen = filn;
/*
- * $Id: ftp.cc,v 1.307 2001/01/12 00:37:17 wessels Exp $
+ * $Id: ftp.cc,v 1.308 2001/03/03 10:39:32 hno Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
HttpReply *reply;
CBDATA_INIT_TYPE(FtpStateData);
- ftpState = CBDATA_ALLOC(FtpStateData, NULL);
+ ftpState = cbdataAlloc(FtpStateData);
debug(9, 3) ("ftpStart: '%s'\n", url);
statCounter.server.all.requests++;
statCounter.server.ftp.requests++;
/*
- * $Id: gopher.cc,v 1.159 2001/01/12 00:37:18 wessels Exp $
+ * $Id: gopher.cc,v 1.160 2001/03/03 10:39:32 hno Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
{
GopherStateData *gd;
CBDATA_INIT_TYPE(GopherStateData);
- gd = CBDATA_ALLOC(GopherStateData, NULL);
+ gd = cbdataAlloc(GopherStateData);
gd->buf = memAllocate(MEM_4K_BUF);
return (gd);
}
/*
- * $Id: helper.cc,v 1.25 2001/01/31 22:16:38 hno Exp $
+ * $Id: helper.cc,v 1.26 2001/03/03 10:39:32 hno Exp $
*
* DEBUG: section 29 Helper process maintenance
* AUTHOR: Harvest Derived?
continue;
}
hlp->n_running++;
- srv = CBDATA_ALLOC(helper_server, NULL);
+ srv = cbdataAlloc(helper_server);
srv->flags.alive = 1;
srv->index = k;
srv->rfd = rfd;
continue;
}
hlp->n_running++;
- srv = CBDATA_ALLOC(helper_stateful_server, NULL);
+ srv = cbdataAlloc(helper_stateful_server);
srv->flags.alive = 1;
srv->flags.reserved = S_HELPER_FREE;
srv->deferred_requests = 0;
helperCreate(const char *name)
{
helper *hlp;
- hlp = CBDATA_ALLOC(helper, NULL);
+ hlp = cbdataAlloc(helper);
hlp->id_name = name;
return hlp;
}
helperStatefulCreate(const char *name)
{
statefulhelper *hlp;
- hlp = CBDATA_ALLOC(statefulhelper, NULL);
+ hlp = cbdataAlloc(statefulhelper);
hlp->id_name = name;
return hlp;
}
/*
- * $Id: http.cc,v 1.377 2001/01/12 00:37:18 wessels Exp $
+ * $Id: http.cc,v 1.378 2001/03/03 10:39:32 hno Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
debug(11, 3) ("httpStart: \"%s %s\"\n",
RequestMethodStr[orig_req->method],
storeUrl(fwd->entry));
- httpState = CBDATA_ALLOC(HttpStateData, NULL);
+ httpState = cbdataAlloc(HttpStateData);
storeLockObject(fwd->entry);
httpState->fwd = fwd;
httpState->entry = fwd->entry;
/*
- * $Id: ident.cc,v 1.56 2001/01/12 00:37:18 wessels Exp $
+ * $Id: ident.cc,v 1.57 2001/03/03 10:39:32 hno Exp $
*
* DEBUG: section 30 Ident (RFC 931)
* AUTHOR: Duane Wessels
return;
}
CBDATA_INIT_TYPE(IdentStateData);
- state = CBDATA_ALLOC(IdentStateData, NULL);
+ state = cbdataAlloc(IdentStateData);
state->hash.key = xstrdup(key);
state->fd = fd;
state->me = *me;
/*
- * $Id: ipcache.cc,v 1.233 2001/02/23 20:59:51 hno Exp $
+ * $Id: ipcache.cc,v 1.234 2001/03/03 10:39:32 hno Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
i->handlerData = handlerData;
cbdataLock(handlerData);
i->request_time = current_time;
- c = CBDATA_ALLOC(generic_cbdata, NULL);
+ c = cbdataAlloc(generic_cbdata);
c->data = i;
#if USE_DNSSERVERS
dnsSubmit(hashKeyStr(&i->hash), ipcacheHandleReply, c);
/*
- * $Id: neighbors.cc,v 1.292 2001/01/12 00:37:19 wessels Exp $
+ * $Id: neighbors.cc,v 1.293 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
p->mcast.flags.count_event_pending = 0;
snprintf(url, MAX_URL, "http://%s/", inet_ntoa(p->in_addr.sin_addr));
fake = storeCreateEntry(url, url, null_request_flags, METHOD_GET);
- psstate = CBDATA_ALLOC(ps_state, NULL);
+ psstate = cbdataAlloc(ps_state);
psstate->request = requestLink(urlParse(METHOD_GET, url));
psstate->entry = fake;
psstate->callback = NULL;
/*
- * $Id: net_db.cc,v 1.156 2001/01/12 00:37:20 wessels Exp $
+ * $Id: net_db.cc,v 1.157 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 38 Network Measurement Database
* AUTHOR: Duane Wessels
if ((n = netdbLookupHost(hostname)) != NULL)
if (n->next_ping_time > squid_curtime)
return;
- h = CBDATA_ALLOC(generic_cbdata, NULL);
+ h = cbdataAlloc(generic_cbdata);
h->data = xstrdup(hostname);
ipcache_nbgethostbyname(hostname, netdbSendPing, h);
#endif
char *uri;
netdbExchangeState *ex;
CBDATA_INIT_TYPE(netdbExchangeState);
- ex = CBDATA_ALLOC(netdbExchangeState, NULL);
+ ex = cbdataAlloc(netdbExchangeState);
cbdataLock(p);
ex->p = p;
uri = internalRemoteUri(p->host, p->http_port, "/squid-internal-dynamic/", "netdb");
/*
- * $Id: peer_digest.cc,v 1.78 2001/02/07 18:56:52 hno Exp $
+ * $Id: peer_digest.cc,v 1.79 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 72 Peer Digest Routines
* AUTHOR: Alex Rousskov
assert(p);
CBDATA_INIT_TYPE(PeerDigest);
- pd = CBDATA_ALLOC(PeerDigest, NULL);
+ pd = cbdataAlloc(PeerDigest);
peerDigestInit(pd, p);
cbdataLock(pd->peer); /* we will use the peer */
if (p->login)
xstrncpy(req->login, p->login, MAX_LOGIN_SZ);
/* create fetch state structure */
- fetch = CBDATA_ALLOC(DigestFetchState, NULL);
+ fetch = cbdataAlloc(DigestFetchState);
fetch->request = requestLink(req);
fetch->pd = pd;
fetch->offset = 0;
/*
- * $Id: peer_select.cc,v 1.113 2001/02/07 18:56:52 hno Exp $
+ * $Id: peer_select.cc,v 1.114 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 44 Peer Selection Algorithm
* AUTHOR: Duane Wessels
debug(44, 3) ("peerSelect: %s\n", storeUrl(entry));
else
debug(44, 3) ("peerSelect: %s\n", RequestMethodStr[request->method]);
- psstate = CBDATA_ALLOC(ps_state, NULL);
+ psstate = cbdataAlloc(ps_state);
psstate->request = requestLink(request);
psstate->entry = entry;
psstate->callback = callback;
/*
- * $Id: protos.h,v 1.399 2001/02/23 20:59:51 hno Exp $
+ * $Id: protos.h,v 1.400 2001/03/03 10:39:33 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
*/
extern void cbdataInit(void);
#if CBDATA_DEBUG
-extern void *cbdataInternalAllocDbg(cbdata_type type, CBDUNL *, int, const char *);
+extern void *cbdataInternalAllocDbg(cbdata_type type, int, const char *);
extern void cbdataLockDbg(const void *p, const char *, int);
extern void cbdataUnlockDbg(const void *p, const char *, int);
#else
-extern void *cbdataInternalAlloc(cbdata_type type, CBDUNL *);
+extern void *cbdataInternalAlloc(cbdata_type type);
extern void cbdataLock(const void *p);
extern void cbdataUnlock(const void *p);
#endif
-/* Note: Allocations is done using the CBDATA_ALLOC macro */
-
-extern void cbdataFree(void *p);
+/* Note: Allocations is done using the cbdataAlloc macro */
+extern void cbdataInternalFree(void *p);
extern int cbdataValid(const void *p);
-extern void cbdataInitType(cbdata_type type, char *label, int size);
-extern cbdata_type cbdataAddType(cbdata_type type, char *label, int size);
+extern void cbdataInitType(cbdata_type type, char *label, int size, FREE * free_func);
+extern cbdata_type cbdataAddType(cbdata_type type, char *label, int size, FREE * free_func);
+extern int cbdataLocked(const void *p);
extern void clientdbInit(void);
extern void clientdbUpdate(struct in_addr, log_type, protocol_t, size_t);
/*
- * $Id: redirect.cc,v 1.87 2001/01/12 00:37:20 wessels Exp $
+ * $Id: redirect.cc,v 1.88 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 29 Redirector
* AUTHOR: Duane Wessels
handler(data, NULL);
return;
}
- r = CBDATA_ALLOC(redirectStateData, NULL);
+ r = cbdataAlloc(redirectStateData);
r->orig_url = xstrdup(http->uri);
r->client_addr = conn->log_addr;
if (http->request->auth_user_request)
/*
- * $Id: store_repl_heap.cc,v 1.5 2001/02/07 18:56:56 hno Exp $
+ * $Id: store_repl_heap.cc,v 1.6 2001/03/03 10:39:39 hno Exp $
*
* DEBUG: section ? HEAP based removal policies
* AUTHOR: Henrik Nordstrom
RemovalPolicyWalker *walker;
HeapWalkData *heap_walk;
heap->nwalkers += 1;
- walker = CBDATA_ALLOC(RemovalPolicyWalker, NULL);
+ walker = cbdataAlloc(RemovalPolicyWalker);
heap_walk = xcalloc(1, sizeof(*heap_walk));
heap_walk->current = 0;
walker->_policy = policy;
RemovalPurgeWalker *walker;
HeapPurgeData *heap_walk;
heap->nwalkers += 1;
- walker = CBDATA_ALLOC(RemovalPurgeWalker, NULL);
+ walker = cbdataAlloc(RemovalPurgeWalker);
heap_walk = xcalloc(1, sizeof(*heap_walk));
heap_walk->min_age = 0.0;
heap_walk->locked_entries = NULL;
HeapPolicyData *heap_data;
char *keytype;
/* Allocate the needed structures */
- policy = CBDATA_ALLOC(RemovalPolicy, NULL);
+ policy = cbdataAlloc(RemovalPolicy);
heap_data = xcalloc(1, sizeof(*heap_data));
/* Initialize the policy data */
heap_data->policy = policy;
/*
- * $Id: store_repl_lru.cc,v 1.7 2001/02/07 18:56:56 hno Exp $
+ * $Id: store_repl_lru.cc,v 1.8 2001/03/03 10:39:39 hno Exp $
*
* DEBUG: section ? LRU Removal policy
* AUTHOR: Henrik Nordstrom
RemovalPolicyWalker *walker;
LruWalkData *lru_walk;
lru->nwalkers += 1;
- walker = CBDATA_ALLOC(RemovalPolicyWalker, NULL);
+ walker = cbdataAlloc(RemovalPolicyWalker);
lru_walk = xcalloc(1, sizeof(*lru_walk));
walker->_policy = policy;
walker->_data = lru_walk;
RemovalPurgeWalker *walker;
LruPurgeData *lru_walk;
lru->nwalkers += 1;
- walker = CBDATA_ALLOC(RemovalPurgeWalker, NULL);
+ walker = cbdataAlloc(RemovalPurgeWalker);
lru_walk = xcalloc(1, sizeof(*lru_walk));
walker->_policy = policy;
walker->_data = lru_walk;
lru_node_pool = memPoolCreate("LRU policy node", sizeof(LruNode));
/* Allocate the needed structures */
lru_data = xcalloc(1, sizeof(*lru_data));
- policy = CBDATA_ALLOC(RemovalPolicy, NULL);
+ policy = cbdataAlloc(RemovalPolicy);
/* Initialize the URL data */
lru_data->policy = policy;
/* Populate the policy structure */
/*
- * $Id: ssl.cc,v 1.111 2001/01/12 00:37:21 wessels Exp $
+ * $Id: ssl.cc,v 1.112 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
return;
}
CBDATA_INIT_TYPE(SslStateData);
- sslState = CBDATA_ALLOC(SslStateData, NULL);
+ sslState = cbdataAlloc(SslStateData);
#if DELAY_POOLS
sslState->delay_id = delayClient(request);
delayRegisterDelayIdPtr(&sslState->delay_id);
/*
- * $Id: stat.cc,v 1.344 2001/02/07 18:56:52 hno Exp $
+ * $Id: stat.cc,v 1.345 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
statObjectsStart(StoreEntry * sentry, STOBJFLT * filter)
{
StatObjectsState *state;
- state = CBDATA_ALLOC(StatObjectsState, NULL);
+ state = cbdataAlloc(StatObjectsState);
state->sentry = sentry;
state->filter = filter;
storeLockObject(sentry);
/*
- * $Id: store_client.cc,v 1.100 2001/01/12 00:37:22 wessels Exp $
+ * $Id: store_client.cc,v 1.101 2001/03/03 10:39:34 hno Exp $
*
* DEBUG: section 20 Storage Manager Client-Side Interface
* AUTHOR: Duane Wessels
#endif
e->refcount++;
mem->nclients++;
- sc = CBDATA_ALLOC(store_client, NULL);
+ sc = cbdataAlloc(store_client);
cbdataLock(data); /* locked while we point to it */
sc->callback_data = data;
sc->seen_offset = 0;
/*
- * $Id: store_digest.cc,v 1.48 2001/02/07 19:09:25 hno Exp $
+ * $Id: store_digest.cc,v 1.49 2001/03/03 10:39:34 hno Exp $
*
* DEBUG: section 71 Store Digest Manager
* AUTHOR: Alex Rousskov
flags.cachable = 1;
e = storeCreateEntry(url, url, flags, METHOD_GET);
assert(e);
- sd_state.rewrite_lock = CBDATA_ALLOC(generic_cbdata, NULL);
+ sd_state.rewrite_lock = cbdataAlloc(generic_cbdata);
sd_state.rewrite_lock->data = e;
debug(71, 3) ("storeDigestRewrite: url: %s key: %s\n", url, storeKeyText(e->hash.key));
e->mem_obj->request = requestLink(urlParse(METHOD_GET, url));
/*
- * $Id: store_swapout.cc,v 1.79 2001/01/12 00:37:22 wessels Exp $
+ * $Id: store_swapout.cc,v 1.80 2001/03/03 10:39:34 hno Exp $
*
* DEBUG: section 20 Storage Manager Swapout Functions
* AUTHOR: Duane Wessels
storeSwapTLVFree(tlv_list);
mem->swap_hdr_sz = (size_t) swap_hdr_sz;
/* Create the swap file */
- c = CBDATA_ALLOC(generic_cbdata, NULL);
+ c = cbdataAlloc(generic_cbdata);
c->data = e;
mem->swapout.sio = storeCreate(e, storeSwapOutFileNotify, storeSwapOutFileClosed, c);
if (NULL == mem->swapout.sio) {
/*
- * $Id: tunnel.cc,v 1.111 2001/01/12 00:37:21 wessels Exp $
+ * $Id: tunnel.cc,v 1.112 2001/03/03 10:39:33 hno Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
return;
}
CBDATA_INIT_TYPE(SslStateData);
- sslState = CBDATA_ALLOC(SslStateData, NULL);
+ sslState = cbdataAlloc(SslStateData);
#if DELAY_POOLS
sslState->delay_id = delayClient(request);
delayRegisterDelayIdPtr(&sslState->delay_id);
/*
- * $Id: urn.cc,v 1.66 2001/02/23 20:59:51 hno Exp $
+ * $Id: urn.cc,v 1.67 2001/03/03 10:39:34 hno Exp $
*
* DEBUG: section 52 URN Parsing
* AUTHOR: Kostas Anagnostakis
ErrorState *err;
debug(52, 3) ("urnStart: '%s'\n", storeUrl(e));
CBDATA_INIT_TYPE(UrnState);
- urnState = CBDATA_ALLOC(UrnState, NULL);
+ urnState = cbdataAlloc(UrnState);
urnState->entry = e;
urnState->request = requestLink(r);
storeLockObject(urnState->entry);
/*
- * $Id: wais.cc,v 1.135 2001/01/12 00:37:23 wessels Exp $
+ * $Id: wais.cc,v 1.136 2001/03/03 10:39:34 hno Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
statCounter.server.all.requests++;
statCounter.server.other.requests++;
CBDATA_INIT_TYPE(WaisStateData);
- waisState = CBDATA_ALLOC(WaisStateData, NULL);
+ waisState = cbdataAlloc(WaisStateData);
waisState->method = method;
waisState->request_hdr = &request->header;
waisState->fd = fd;
/*
- * $Id: whois.cc,v 1.14 2001/01/12 00:37:23 wessels Exp $
+ * $Id: whois.cc,v 1.15 2001/03/03 10:39:34 hno Exp $
*
* DEBUG: section 75 WHOIS protocol
* AUTHOR: Duane Wessels, Kostas Anagnostakis
char *buf;
size_t l;
CBDATA_INIT_TYPE(WhoisState);
- p = CBDATA_ALLOC(WhoisState, NULL);
+ p = cbdataAlloc(WhoisState);
p->request = fwd->request;
p->entry = fwd->entry;
p->fwd = fwd;