From: hno <> Date: Sat, 3 Mar 2001 17:39:29 +0000 (+0000) Subject: cbdata now have a per-type free function rather than per allocation. X-Git-Tag: SQUID_3_0_PRE1~1580 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=72711e319152bb701c15833f72a8aab2d5035bdc;p=thirdparty%2Fsquid.git cbdata now have a per-type free function rather than per allocation. Changes to the API: To initialize a new CBDATA type with a free function: CBDATA_INIT_TYPE_FREECB(typename, freefunction); To allocate a cbdata structure var = cbdataAlloc(typename); (was CBDATA_ALLOC(typename, freefunc) ) --- diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml index be443093ed..a195500094 100644 --- a/doc/Programming-Guide/prog-guide.sgml +++ b/doc/Programming-Guide/prog-guide.sgml @@ -2,7 +2,7 @@
Squid Programmers Guide Duane Wessels, Squid Developers -$Id: prog-guide.sgml,v 1.35 2001/01/31 22:16:36 hno Exp $ +$Id: prog-guide.sgml,v 1.36 2001/03/03 10:39:29 hno Exp $ Squid is a WWW Cache application developed by the National Laboratory @@ -2411,7 +2411,7 @@ coupling between the storage layer and the replacement policy. 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); @@ -2427,7 +2427,7 @@ coupling between the storage layer and the replacement policy. With this scheme, nothing bad happens if - callback_data = CBDATA_ALLOC(...); + callback_data = cbdataAlloc(...); ... cbdataLock(callback_data); fooOperationStart(bar, callback_func, callback_data); @@ -2449,7 +2449,7 @@ coupling between the storage layer and the replacement policy.

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. @@ -2463,6 +2463,8 @@ coupling between the storage layer and the replacement policy. * (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);

@@ -2476,10 +2478,6 @@ coupling between the storage layer and the replacement policy. extern CBDATA_GLOBAL_TYPE(type_of_data); /* CBDATA_UNDEF */ -

- TODO: Restructure the free function so there is one free function - associated with the whole cbdata type rather than per allocation. - Cache Manager diff --git a/src/acl.cc b/src/acl.cc index b978e98bb3..d1983e3c1b 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -967,7 +967,7 @@ aclParseAccessLine(acl_access ** head) 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; @@ -1933,7 +1933,7 @@ aclChecklistCreate(const acl_access * A, { 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 diff --git a/src/asn.cc b/src/asn.cc index cbe98e318b..93ed133ce0 100644 --- a/src/asn.cc +++ b/src/asn.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -187,7 +187,7 @@ asnCacheStart(int as) 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; diff --git a/src/auth/basic/auth_basic.cc b/src/auth/basic/auth_basic.cc index d3081dccd5..c0208ad2ba 100644 --- a/src/auth/basic/auth_basic.cc +++ b/src/auth/basic/auth_basic.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -378,6 +378,7 @@ static void authBasicDataFree(basic_data * basic_auth) { } + #endif static auth_user_t * @@ -588,7 +589,7 @@ authenticateBasicStart(auth_user_request_t * auth_user_request, RH * handler, vo cbdataLock(data); return; } else { - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index ae909dcb5e..71c5c0251d 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -200,7 +200,7 @@ authenticateDigestNonceDelete(digest_nonce_h * nonce) } } -void +void authenticateDigestNonceSetup() { if (!digest_nonce_pool) @@ -212,7 +212,7 @@ authenticateDigestNonceSetup() } } -void +void authenticateDigestNonceShutdown() { /* @@ -235,7 +235,7 @@ authenticateDigestNonceShutdown() debug(29, 2) ("authenticateDigestNonceShutdown: Nonce cache shutdown\n"); } -void +void authenticateDigestNonceReconfigure() { } @@ -690,7 +690,7 @@ authenticateDigestAuthenticateUser(auth_user_request_t * auth_user_request, requ return; } -int +int authenticateDigestDirection(auth_user_request_t * auth_user_request) { digest_request_h *digest_request; @@ -1313,7 +1313,7 @@ authenticateDigestStart(auth_user_request_t * auth_user_request, RH * handler, v handler(data, NULL); return; } - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; diff --git a/src/auth/ntlm/auth_ntlm.cc b/src/auth/ntlm/auth_ntlm.cc index 31079c1e07..dd31a26b08 100644 --- a/src/auth/ntlm/auth_ntlm.cc +++ b/src/auth/ntlm/auth_ntlm.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -625,7 +625,7 @@ authenticateNTLMStart(auth_user_request_t * auth_user_request, RH * handler, voi return; } #ifdef NTLMHELPPROTOCOLV2 - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; @@ -663,7 +663,7 @@ authenticateNTLMStart(auth_user_request_t * auth_user_request, RH * handler, voi 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; @@ -687,7 +687,7 @@ authenticateNTLMStart(auth_user_request_t * auth_user_request, RH * handler, voi break; case AUTHENTICATE_STATE_RESPONSE: - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index ae23fc855e..35123e4ec7 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -380,7 +380,7 @@ configDoConfigure(void) 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; } @@ -778,7 +778,7 @@ dump_http_header_access(StoreEntry * entry, const char *name, header_mangler hea 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); } @@ -811,9 +811,9 @@ parse_http_header_access(header_mangler header[]) 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); @@ -1246,7 +1246,7 @@ parse_peer(peer ** head) 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; diff --git a/src/cbdata.cc b/src/cbdata.cc index ea1f661eee..85630f1d51 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -71,8 +71,7 @@ static int cbdataCount = 0; 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; @@ -87,36 +86,40 @@ typedef struct _cbdata { 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; } @@ -127,7 +130,8 @@ cbdataInit(void) 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); @@ -140,27 +144,25 @@ cbdataInit(void) 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 @@ -174,11 +176,13 @@ cbdataInternalAlloc(cbdata_type type, CBDUNL * free_func) } 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; @@ -189,9 +193,22 @@ cbdataFree(void *p) } 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 @@ -223,6 +240,7 @@ cbdataUnlock(const void *p) #endif { cbdata *c; + FREE *free_func; if (p == NULL) return; c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data)); @@ -239,9 +257,10 @@ cbdataUnlock(const void *p) 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 diff --git a/src/client_side.cc b/src/client_side.cc index 9f03ee92b0..619417eebb 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -2302,7 +2302,7 @@ static clientHttpRequest * 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; @@ -2441,7 +2441,7 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status, 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; @@ -3074,7 +3074,7 @@ httpAccept(int sock, void *data) 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; diff --git a/src/comm.cc b/src/comm.cc index f332d1b7bd..76a092da58 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -232,7 +232,7 @@ commConnectStart(int fd, const char *host, u_short port, CNCB * callback, void * { 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; diff --git a/src/defines.h b/src/defines.h index 4088d25326..e4808fbc4b 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ /* - * $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/ @@ -281,10 +281,12 @@ #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 diff --git a/src/enums.h b/src/enums.h index 500bdf02bb..783fb8adac 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $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/ @@ -753,6 +753,5 @@ typedef enum { CBDATA_RemovalPolicyWalker, CBDATA_RemovalPurgeWalker, CBDATA_store_client, - CBDATA_storeIOState, CBDATA_FIRST_CUSTOM_TYPE = 1000 } cbdata_type; diff --git a/src/errorpage.cc b/src/errorpage.cc index ea244f2b1d..2c64294997 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -235,7 +235,7 @@ ErrorState * 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; diff --git a/src/forward.cc b/src/forward.cc index d2fa080552..3def297393 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -544,7 +544,7 @@ fwdStart(int fd, StoreEntry * e, request_t * r) default: break; } - fwdState = CBDATA_ALLOC(FwdState, NULL); + fwdState = cbdataAlloc(FwdState); fwdState->entry = e; fwdState->client_fd = fd; fwdState->server_fd = -1; diff --git a/src/fqdncache.cc b/src/fqdncache.cc index bfa646d6ed..deef6e0f63 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -387,7 +387,7 @@ fqdncache_nbgethostbyaddr(struct in_addr addr, FQDNH * handler, void *handlerDat 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); diff --git a/src/fs/aufs/store_dir_aufs.cc b/src/fs/aufs/store_dir_aufs.cc index 31d7aa1b4e..b434886721 100644 --- a/src/fs/aufs/store_dir_aufs.cc +++ b/src/fs/aufs/store_dir_aufs.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -829,7 +829,7 @@ storeAufsDirRebuild(SwapDir * sd) 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; /* diff --git a/src/fs/aufs/store_io_aufs.cc b/src/fs/aufs/store_io_aufs.cc index 838d96089d..f3fc995428 100644 --- a/src/fs/aufs/store_io_aufs.cc +++ b/src/fs/aufs/store_io_aufs.cc @@ -22,6 +22,8 @@ static int storeAufsSomethingPending(storeIOState *); static int storeAufsKickWriteQueue(storeIOState * sio); static CBDUNL storeAufsIOFreeEntry; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ /* open for reading */ @@ -51,7 +53,8 @@ storeAufsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, 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; @@ -105,7 +108,8 @@ storeAufsCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * c 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; diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 606d1382d1..7982c0c386 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -339,7 +339,7 @@ storeCossDirRebuild(SwapDir * sd) 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; diff --git a/src/fs/coss/store_io_coss.cc b/src/fs/coss/store_io_coss.cc index 3c91f702f8..601e00ffb4 100644 --- a/src/fs/coss/store_io_coss.cc +++ b/src/fs/coss/store_io_coss.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -49,6 +49,8 @@ static CossMemBuf *storeCossCreateMemBuf(SwapDir * SD, size_t start, static CBDUNL storeCossIOFreeEntry; static CBDUNL storeCossMembufFree; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ /* @@ -128,7 +130,8 @@ storeCossCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * c 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; @@ -172,7 +175,8 @@ storeCossOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, 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; @@ -477,8 +481,8 @@ storeCossCreateMemBuf(SwapDir * SD, size_t start, 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; diff --git a/src/fs/diskd/store_dir_diskd.cc b/src/fs/diskd/store_dir_diskd.cc index 22c621be16..0b93c8c187 100644 --- a/src/fs/diskd/store_dir_diskd.cc +++ b/src/fs/diskd/store_dir_diskd.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -1021,7 +1021,7 @@ storeDiskdDirRebuild(SwapDir * sd) 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; /* @@ -1706,7 +1706,7 @@ storeDiskdDirStats(SwapDir * SD, StoreEntry * sentry) 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; @@ -1716,7 +1716,7 @@ storeDiskdDirParseQ1(SwapDir * sd, const char *name, const char *value, int reco 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; diff --git a/src/fs/diskd/store_io_diskd.cc b/src/fs/diskd/store_io_diskd.cc index b813adf307..0220aa3242 100644 --- a/src/fs/diskd/store_io_diskd.cc +++ b/src/fs/diskd/store_io_diskd.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -46,6 +46,8 @@ static int storeDiskdSend(int, SwapDir *, int, storeIOState *, int, int, int); static void storeDiskdIOCallback(storeIOState * sio, int errflag); static CBDUNL storeDiskdIOFreeEntry; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ storeIOState * @@ -68,7 +70,8 @@ storeDiskdOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, 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; @@ -126,7 +129,8 @@ storeDiskdCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, 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; diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 0d5f8037a2..f9abeeda63 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -825,7 +825,7 @@ storeUfsDirRebuild(SwapDir * sd) 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; /* diff --git a/src/fs/ufs/store_io_ufs.cc b/src/fs/ufs/store_io_ufs.cc index 212b06c0b2..9734d3b540 100644 --- a/src/fs/ufs/store_io_ufs.cc +++ b/src/fs/ufs/store_io_ufs.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -42,6 +42,8 @@ static DWCB storeUfsWriteDone; static void storeUfsIOCallback(storeIOState * sio, int errflag); static CBDUNL storeUfsIOFreeEntry; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ storeIOState * @@ -60,7 +62,8 @@ storeUfsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, 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; @@ -107,7 +110,8 @@ storeUfsCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * ca 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; diff --git a/src/ftp.cc b/src/ftp.cc index bf5bf2530f..60717dc378 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -1047,7 +1047,7 @@ ftpStart(FwdState * fwd) 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++; diff --git a/src/gopher.cc b/src/gopher.cc index 0d33917719..76d3c8f6f5 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -818,7 +818,7 @@ CreateGopherStateData(void) { GopherStateData *gd; CBDATA_INIT_TYPE(GopherStateData); - gd = CBDATA_ALLOC(GopherStateData, NULL); + gd = cbdataAlloc(GopherStateData); gd->buf = memAllocate(MEM_4K_BUF); return (gd); } diff --git a/src/helper.cc b/src/helper.cc index 97aea67012..ccb5528a15 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -1,6 +1,6 @@ /* - * $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? @@ -103,7 +103,7 @@ helperOpenServers(helper * hlp) continue; } hlp->n_running++; - srv = CBDATA_ALLOC(helper_server, NULL); + srv = cbdataAlloc(helper_server); srv->flags.alive = 1; srv->index = k; srv->rfd = rfd; @@ -179,7 +179,7 @@ helperStatefulOpenServers(statefulhelper * hlp) 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; @@ -537,7 +537,7 @@ helper * helperCreate(const char *name) { helper *hlp; - hlp = CBDATA_ALLOC(helper, NULL); + hlp = cbdataAlloc(helper); hlp->id_name = name; return hlp; } @@ -546,7 +546,7 @@ statefulhelper * helperStatefulCreate(const char *name) { statefulhelper *hlp; - hlp = CBDATA_ALLOC(statefulhelper, NULL); + hlp = cbdataAlloc(statefulhelper); hlp->id_name = name; return hlp; } diff --git a/src/http.cc b/src/http.cc index 93eb5730ff..ae0dabaece 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -928,7 +928,7 @@ httpStart(FwdState * fwd) 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; diff --git a/src/ident.cc b/src/ident.cc index 63b143baed..ca4e335e82 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -216,7 +216,7 @@ identStart(struct sockaddr_in *me, struct sockaddr_in *my_peer, IDCB * callback, return; } CBDATA_INIT_TYPE(IdentStateData); - state = CBDATA_ALLOC(IdentStateData, NULL); + state = cbdataAlloc(IdentStateData); state->hash.key = xstrdup(key); state->fd = fd; state->me = *me; diff --git a/src/ipcache.cc b/src/ipcache.cc index b7cd66ed9d..b7dca00b54 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -432,7 +432,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData) 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); diff --git a/src/neighbors.cc b/src/neighbors.cc index 5f32d7bbf1..a134a3adf9 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -1123,7 +1123,7 @@ peerCountMcastPeersStart(void *data) 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; diff --git a/src/net_db.cc b/src/net_db.cc index acfa1b5ef7..1a36a31420 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -682,7 +682,7 @@ netdbPingSite(const char *hostname) 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 @@ -991,7 +991,7 @@ netdbExchangeStart(void *data) 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"); diff --git a/src/peer_digest.cc b/src/peer_digest.cc index aad9bbea76..033e62c2e9 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -107,7 +107,7 @@ peerDigestCreate(peer * p) 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 */ @@ -295,7 +295,7 @@ peerDigestRequest(PeerDigest * pd) 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; diff --git a/src/peer_select.cc b/src/peer_select.cc index 91687ce6d9..97afc178d8 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -139,7 +139,7 @@ peerSelect(request_t * request, 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; diff --git a/src/protos.h b/src/protos.h index 117f8d584b..8066b44dc6 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $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/ @@ -101,20 +101,20 @@ extern void parse_cachedir_options(SwapDir * sd, struct cache_dir_option *option */ 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); diff --git a/src/redirect.cc b/src/redirect.cc index d2ffb072a2..60f11c50ed 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -123,7 +123,7 @@ redirectStart(clientHttpRequest * http, RH * handler, void *data) 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) diff --git a/src/repl/heap/store_repl_heap.cc b/src/repl/heap/store_repl_heap.cc index fb3413531d..75e4d8588b 100644 --- a/src/repl/heap/store_repl_heap.cc +++ b/src/repl/heap/store_repl_heap.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -151,7 +151,7 @@ heap_walkInit(RemovalPolicy * policy) 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; @@ -224,7 +224,7 @@ heap_purgeInit(RemovalPolicy * policy, int max_scan) 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; @@ -262,7 +262,7 @@ createRemovalPolicy_heap(wordlist * args) 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; diff --git a/src/repl/lru/store_repl_lru.cc b/src/repl/lru/store_repl_lru.cc index 9b963cb9cc..851e13bae0 100644 --- a/src/repl/lru/store_repl_lru.cc +++ b/src/repl/lru/store_repl_lru.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -162,7 +162,7 @@ lru_walkInit(RemovalPolicy * policy) 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; @@ -231,7 +231,7 @@ lru_purgeInit(RemovalPolicy * policy, int max_scan) 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; @@ -268,7 +268,7 @@ createRemovalPolicy_lru(wordlist * args) 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 */ diff --git a/src/ssl.cc b/src/ssl.cc index 93f65a943c..8c155f0834 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -484,7 +484,7 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr, int *s 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); diff --git a/src/stat.cc b/src/stat.cc index ab0072a4b7..33041914ae 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -345,7 +345,7 @@ static void statObjectsStart(StoreEntry * sentry, STOBJFLT * filter) { StatObjectsState *state; - state = CBDATA_ALLOC(StatObjectsState, NULL); + state = cbdataAlloc(StatObjectsState); state->sentry = sentry; state->filter = filter; storeLockObject(sentry); diff --git a/src/store_client.cc b/src/store_client.cc index 5e6e998752..006426ae75 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -133,7 +133,7 @@ storeClientListAdd(StoreEntry * e, void *data) #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; diff --git a/src/store_digest.cc b/src/store_digest.cc index 4a7c773805..393bdf4b83 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -352,7 +352,7 @@ storeDigestRewriteStart(void *datanotused) 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)); diff --git a/src/store_swapout.cc b/src/store_swapout.cc index dc02fc7533..18698ff0fb 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -61,7 +61,7 @@ storeSwapOutStart(StoreEntry * e) 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) { diff --git a/src/tunnel.cc b/src/tunnel.cc index 6a38383ee5..54e54c5411 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -484,7 +484,7 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr, int *s 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); diff --git a/src/urn.cc b/src/urn.cc index cee72c10d7..28a5cbf947 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -108,7 +108,7 @@ urnStart(request_t * r, StoreEntry * e) 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); diff --git a/src/wais.cc b/src/wais.cc index 4369c3fb6e..c3b429a825 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -230,7 +230,7 @@ waisStart(FwdState * fwd) 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; diff --git a/src/whois.cc b/src/whois.cc index e6bf2ffddd..9797c627b9 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -59,7 +59,7 @@ whoisStart(FwdState * fwd) 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;