--------------------- PatchSet 1095 Date: 2001/01/05 15:33:10 Author: adri Branch: modio Tag: (none) Log: * Pass a new field to storeCreateEntry - the reply_obj_t. This tells us which reply object we need to bind to the StoreEntry during creation. * modify all the calls to storeCreateEntry() based on whether they are internally or network-generated replies. I am pretty sure I got everything right. Members: src/asn.c:1.2.2.7->1.2.2.8 src/client_side.c:1.2.2.9->1.2.2.10 src/enums.h:1.2.2.3->1.2.2.4 src/mime.c:1.2.2.5->1.2.2.6 src/neighbors.c:1.2.2.2->1.2.2.3 src/net_db.c:1.2.2.4->1.2.2.5 src/peer_digest.c:1.2.2.3->1.2.2.4 src/protos.h:1.2.2.12->1.2.2.13 src/pump.c:1.2.2.5->1.2.2.6 src/store.c:1.2.2.15->1.2.2.16 src/store_digest.c:1.2.2.2->1.2.2.3 src/urn.c:1.2.2.4->1.2.2.5 Index: squid/src/asn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/asn.c,v retrieving revision 1.2.2.7 retrieving revision 1.2.2.8 diff -u -r1.2.2.7 -r1.2.2.8 --- squid/src/asn.c 20 Dec 2000 15:45:55 -0000 1.2.2.7 +++ squid/src/asn.c 5 Jan 2001 15:33:10 -0000 1.2.2.8 @@ -1,6 +1,6 @@ /* - * $Id: asn.c,v 1.2.2.7 2000/12/20 15:45:55 adri Exp $ + * $Id: asn.c,v 1.2.2.8 2001/01/05 15:33:10 adri Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -196,7 +196,9 @@ assert(NULL != req); asState->request = requestLink(req); if ((e = storeGetPublic(asres, METHOD_GET)) == NULL) { - e = storeCreateEntry(asres, asres, null_request_flags, METHOD_GET); + /* I'm guessing that this should be private .. */ + e = storeCreateEntry(asres, asres, null_request_flags, METHOD_GET, + REPLY_OBJ_INTERNAL); storeClientRegister(e, asState); fwdStart(-1, e, asState->request); } else { Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.2.2.9 retrieving revision 1.2.2.10 diff -u -r1.2.2.9 -r1.2.2.10 --- squid/src/client_side.c 4 Jan 2001 14:23:12 -0000 1.2.2.9 +++ squid/src/client_side.c 5 Jan 2001 15:33:10 -0000 1.2.2.10 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.2.2.9 2001/01/04 14:23:12 adri Exp $ + * $Id: client_side.c,v 1.2.2.10 2001/01/05 15:33:10 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -203,7 +203,8 @@ } StoreEntry * -clientCreateStoreEntry(clientHttpRequest * h, method_t m, request_flags flags) +clientCreateStoreEntry(clientHttpRequest * h, method_t m, request_flags flags, + reply_obj_t reply_obj) { StoreEntry *e; /* @@ -212,9 +213,7 @@ */ if (h->request == NULL) h->request = requestLink(requestCreate(m, PROTO_NONE, null_string)); - e = storeCreateEntry(h->uri, h->log_uri, flags, m); - /* XXX just for testing! */ - reply_internal_create(e); + e = storeCreateEntry(h->uri, h->log_uri, flags, m, reply_obj); storeClientRegister(e, h); #if DELAY_POOLS delaySetStoreClient(h->sc, delayClient(h->request)); @@ -260,7 +259,7 @@ page_id = aclGetDenyInfoPage(&Config.denyInfoList, AclMatchedName); http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, http->request->method, - null_request_flags); + null_request_flags, REPLY_OBJ_INTERNAL); if (answer == ACCESS_REQ_PROXY_AUTH || aclIsProxyAuth(AclMatchedName)) { if (!http->flags.accel) { /* Proxy authorisation needed */ @@ -387,7 +386,8 @@ entry = storeCreateEntry(url, http->log_uri, http->request->flags, - http->request->method); + http->request->method, + REPLY_OBJ_NETWORK); /* NOTE, don't call storeLockObject(), storeCreateEntry() does it */ storeClientRegister(entry, http); #if DELAY_POOLS @@ -602,7 +602,8 @@ err = errorCon(ERR_ACCESS_DENIED, HTTP_FORBIDDEN); err->request = requestLink(http->request); err->src_addr = http->conn->peer.sin_addr; - http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, http->request->method, + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); return; } @@ -621,7 +622,8 @@ * Make a new entry to hold the reply to be written * to the client. */ - http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, http->request->method, + null_request_flags, REPLY_OBJ_INTERNAL); httpReplyReset(r = http->entry->mem_obj->reply); httpBuildVersion(&version, 1, 0); httpReplySetHeaders(r, version, status, NULL, NULL, 0, 0, -1); @@ -1469,7 +1471,8 @@ http->log_type = LOG_TCP_IMS_HIT; storeClientUnregister(e, http); storeUnlockObject(e); - e = clientCreateStoreEntry(http, http->request->method, null_request_flags); + e = clientCreateStoreEntry(http, http->request->method, + null_request_flags, REPLY_OBJ_INTERNAL); /* * Copy timestamp from the original entry so the 304 * reply has a meaningful Age: header. @@ -1736,7 +1739,7 @@ storeClientUnregister(http->entry, http); storeUnlockObject(http->entry); http->entry = clientCreateStoreEntry(http, http->request->method, - null_request_flags); + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); httpReplyDestroy(rep); return; @@ -1973,7 +1976,8 @@ storeClientUnregister(http->entry, http); storeUnlockObject(http->entry); } - http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, r->method, null_request_flags, + REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); } @@ -2117,7 +2121,8 @@ return; } else if (r->method == METHOD_TRACE) { if (r->max_forwards == 0) { - http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, r->method, + null_request_flags, REPLY_OBJ_INTERNAL); storeReleaseRequest(http->entry); storeBuffer(http->entry); rep = httpReplyCreate(); @@ -2205,12 +2210,14 @@ err = errorCon(ERR_ACCESS_DENIED, HTTP_FORBIDDEN); err->request = requestLink(r); err->src_addr = http->conn->peer.sin_addr; - http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, r->method, + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); return; } assert(http->out.offset == 0); - http->entry = clientCreateStoreEntry(http, r->method, r->flags); + http->entry = clientCreateStoreEntry(http, r->method, r->flags, + REPLY_OBJ_NETWORK); if (http->redirect.status) { HttpReply *rep = httpReplyCreate(); #if LOG_TCP_REDIRECTS @@ -2627,7 +2634,8 @@ debug(33, 1) ("clientReadRequest: FD %d Invalid Request\n", fd); err = errorCon(ERR_INVALID_REQ, HTTP_BAD_REQUEST); err->request_hdrs = xstrdup(conn->in.buf); - http->entry = clientCreateStoreEntry(http, method, null_request_flags); + http->entry = clientCreateStoreEntry(http, method, + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); safe_free(prefix); break; @@ -2638,7 +2646,8 @@ err->src_addr = conn->peer.sin_addr; err->url = xstrdup(http->uri); http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, method, null_request_flags); + http->entry = clientCreateStoreEntry(http, method, + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); safe_free(prefix); break; @@ -2682,7 +2691,8 @@ err->request = requestLink(request); request->flags.proxy_keepalive = 0; http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, request->method, + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); break; } @@ -2691,7 +2701,8 @@ err->src_addr = conn->peer.sin_addr; err->request = requestLink(request); http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, request->method, + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); break; } @@ -2731,7 +2742,7 @@ err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE); err->request = requestLink(request); http->entry = clientCreateStoreEntry(http, - METHOD_NONE, null_request_flags); + METHOD_NONE, null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); break; } @@ -2756,7 +2767,8 @@ /* add to the client request queue */ for (H = &conn->chr; *H; H = &(*H)->next); *H = http; - http->entry = clientCreateStoreEntry(http, METHOD_NONE, null_request_flags); + http->entry = clientCreateStoreEntry(http, METHOD_NONE, + null_request_flags, REPLY_OBJ_INTERNAL); errorAppendEntry(http->entry, err); return; } Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.2.2.3 retrieving revision 1.2.2.4 diff -u -r1.2.2.3 -r1.2.2.4 --- squid/src/enums.h 13 Dec 2000 07:57:54 -0000 1.2.2.3 +++ squid/src/enums.h 5 Jan 2001 15:33:10 -0000 1.2.2.4 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.2.2.3 2000/12/13 07:57:54 adri Exp $ + * $Id: enums.h,v 1.2.2.4 2001/01/05 15:33:10 adri Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -675,3 +675,12 @@ NETDB_EX_RTT, NETDB_EX_HOPS }; + +/* + * reply object types + */ +typedef enum { + REPLY_OBJ_NONE, + REPLY_OBJ_INTERNAL, + REPLY_OBJ_NETWORK +} reply_obj_t; Index: squid/src/mime.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mime.c,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -u -r1.2.2.5 -r1.2.2.6 --- squid/src/mime.c 2 Jan 2001 14:05:32 -0000 1.2.2.5 +++ squid/src/mime.c 5 Jan 2001 15:33:10 -0000 1.2.2.6 @@ -1,6 +1,6 @@ /* - * $Id: mime.c,v 1.2.2.5 2001/01/02 14:05:32 adri Exp $ + * $Id: mime.c,v 1.2.2.6 2001/01/05 15:33:10 adri Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -421,12 +421,10 @@ e = storeCreateEntry(url, url, flags, - METHOD_GET); + METHOD_GET, + REPLY_OBJ_NETWORK); assert(e != NULL); - /* this should become a network reply object afterwards.. -- adrian */ - reply_internal_create(e); - storeSetPublicKey(e); storeBuffer(e); e->mem_obj->request = requestLink(urlParse(METHOD_GET, url)); Index: squid/src/neighbors.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/neighbors.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- squid/src/neighbors.c 13 Dec 2000 07:57:55 -0000 1.2.2.2 +++ squid/src/neighbors.c 5 Jan 2001 15:33:10 -0000 1.2.2.3 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.c,v 1.2.2.2 2000/12/13 07:57:55 adri Exp $ + * $Id: neighbors.c,v 1.2.2.3 2001/01/05 15:33:10 adri Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -1123,7 +1123,8 @@ assert(p->type == PEER_MULTICAST); 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); + fake = storeCreateEntry(url, url, null_request_flags, METHOD_GET, + REPLY_OBJ_INTERNAL); psstate->request = requestLink(urlParse(METHOD_GET, url)); psstate->entry = fake; psstate->callback = NULL; Index: squid/src/net_db.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/net_db.c,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -u -r1.2.2.4 -r1.2.2.5 --- squid/src/net_db.c 20 Dec 2000 12:41:22 -0000 1.2.2.4 +++ squid/src/net_db.c 5 Jan 2001 15:33:11 -0000 1.2.2.5 @@ -1,6 +1,6 @@ /* - * $Id: net_db.c,v 1.2.2.4 2000/12/20 12:41:22 adri Exp $ + * $Id: net_db.c,v 1.2.2.5 2001/01/05 15:33:11 adri Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -1001,7 +1001,8 @@ requestLink(ex->r); assert(NULL != ex->r); httpBuildVersion(&ex->r->http_ver, 1, 0); - ex->e = storeCreateEntry(uri, uri, null_request_flags, METHOD_GET); + ex->e = storeCreateEntry(uri, uri, null_request_flags, METHOD_GET, + REPLY_OBJ_INTERNAL); ex->buf_sz = 4096; ex->buf = memAllocate(MEM_4K_BUF); assert(NULL != ex->e); Index: squid/src/peer_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/peer_digest.c,v retrieving revision 1.2.2.3 retrieving revision 1.2.2.4 diff -u -r1.2.2.3 -r1.2.2.4 --- squid/src/peer_digest.c 5 Jan 2001 12:27:48 -0000 1.2.2.3 +++ squid/src/peer_digest.c 5 Jan 2001 15:33:11 -0000 1.2.2.4 @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.c,v 1.2.2.3 2001/01/05 12:27:48 adri Exp $ + * $Id: peer_digest.c,v 1.2.2.4 2001/01/05 15:33:11 adri Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -312,7 +312,8 @@ storeCreateMemObject(old_e, url, url); fetch->old_sc = storeClientRegister(old_e, fetch); } - e = fetch->entry = storeCreateEntry(url, url, req->flags, req->method); + e = fetch->entry = storeCreateEntry(url, url, req->flags, req->method, + REPLY_OBJ_NETWORK); assert(EBIT_TEST(e->flags, KEY_PRIVATE)); fetch->sc = storeClientRegister(e, fetch); /* set lastmod to trigger IMS request if possible */ Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.2.2.12 retrieving revision 1.2.2.13 diff -u -r1.2.2.12 -r1.2.2.13 --- squid/src/protos.h 5 Jan 2001 14:28:21 -0000 1.2.2.12 +++ squid/src/protos.h 5 Jan 2001 15:33:11 -0000 1.2.2.13 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.2.2.12 2001/01/05 14:28:21 adri Exp $ + * $Id: protos.h,v 1.2.2.13 2001/01/05 15:33:11 adri Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -115,7 +115,8 @@ extern int checkNegativeHit(StoreEntry *); extern void clientHttpConnectionsOpen(void); extern void clientHttpConnectionsClose(void); -extern StoreEntry *clientCreateStoreEntry(clientHttpRequest *, method_t, request_flags); +extern StoreEntry *clientCreateStoreEntry(clientHttpRequest *, method_t, + request_flags, reply_obj_t); extern int isTcpHit(log_type); extern int commSetNonBlocking(int fd); @@ -812,7 +813,8 @@ extern StoreEntry *new_StoreEntry(int, const char *, const char *); extern StoreEntry *storeGet(const cache_key *); extern StoreEntry *storeGetPublic(const char *uri, const method_t method); -extern StoreEntry *storeCreateEntry(const char *, const char *, request_flags, method_t); +extern StoreEntry *storeCreateEntry(const char *, const char *, request_flags, + method_t, reply_obj_t); extern void storeSetPublicKey(StoreEntry *); extern void storeComplete(StoreEntry *); extern void storeInit(void); Index: squid/src/pump.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/pump.c,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -u -r1.2.2.5 -r1.2.2.6 --- squid/src/pump.c 27 Dec 2000 11:04:06 -0000 1.2.2.5 +++ squid/src/pump.c 5 Jan 2001 15:33:11 -0000 1.2.2.6 @@ -1,6 +1,6 @@ /* - * $Id: pump.c,v 1.2.2.5 2000/12/27 11:04:06 adri Exp $ + * $Id: pump.c,v 1.2.2.6 2001/01/05 15:33:11 adri Exp $ * * DEBUG: section 61 PUMP handler * AUTHOR: Kostas Anagnostakis @@ -71,7 +71,8 @@ flags.nocache = 1; snprintf(new_key, MAX_URL + 5, "%s|Pump", uri); cbdataAdd(p, memFree, MEM_PUMP_STATE_DATA); - p->request_entry = storeCreateEntry(new_key, new_key, flags, r->method); + p->request_entry = storeCreateEntry(new_key, new_key, flags, r->method, + REPLY_OBJ_INTERNAL); storeClientRegister(p->request_entry, p); EBIT_SET(p->request_entry->flags, ENTRY_DONT_LOG); #if DELAY_POOLS Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.2.2.15 retrieving revision 1.2.2.16 diff -u -r1.2.2.15 -r1.2.2.16 --- squid/src/store.c 27 Dec 2000 13:15:21 -0000 1.2.2.15 +++ squid/src/store.c 5 Jan 2001 15:33:11 -0000 1.2.2.16 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.2.2.15 2000/12/27 13:15:21 adri Exp $ + * $Id: store.c,v 1.2.2.16 2001/01/05 15:33:11 adri Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -353,7 +353,8 @@ } StoreEntry * -storeCreateEntry(const char *url, const char *log_url, request_flags flags, method_t method) +storeCreateEntry(const char *url, const char *log_url, request_flags flags, + method_t method, reply_obj_t reply_obj) { StoreEntry *e = NULL; MemObject *mem = NULL; @@ -365,6 +366,18 @@ mem->method = method; dlinkAdd(e, &e->node, &store_list); + switch (reply_obj) { + case REPLY_OBJ_INTERNAL: + reply_internal_create(e); + break; + case REPLY_OBJ_NETWORK: + reply_network_create(e); + break; + default: + fatal("No valid reply_obj given to storeCreateEntry!\n"); + /* NOTREACHED */ + } + if (neighbors_do_private_keys || !flags.hierarchical) storeSetPrivateKey(e); else Index: squid/src/store_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_digest.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- squid/src/store_digest.c 2 Dec 2000 22:45:14 -0000 1.2.2.2 +++ squid/src/store_digest.c 5 Jan 2001 15:33:11 -0000 1.2.2.3 @@ -1,6 +1,6 @@ /* - * $Id: store_digest.c,v 1.2.2.2 2000/12/02 22:45:14 adri Exp $ + * $Id: store_digest.c,v 1.2.2.3 2001/01/05 15:33:11 adri Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -350,7 +350,8 @@ url = internalLocalUri("/squid-internal-periodic/", StoreDigestFileName); flags = null_request_flags; flags.cachable = 1; - sd_state.rewrite_lock = e = storeCreateEntry(url, url, flags, METHOD_GET); + sd_state.rewrite_lock = e = storeCreateEntry(url, url, flags, METHOD_GET, + REPLY_OBJ_NETWORK); assert(sd_state.rewrite_lock); cbdataAdd(sd_state.rewrite_lock, NULL, 0); debug(71, 3) ("storeDigestRewrite: url: %s key: %s\n", url, storeKeyText(e->hash.key)); Index: squid/src/urn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/urn.c,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -u -r1.2.2.4 -r1.2.2.5 --- squid/src/urn.c 20 Dec 2000 12:41:22 -0000 1.2.2.4 +++ squid/src/urn.c 5 Jan 2001 15:33:11 -0000 1.2.2.5 @@ -1,6 +1,6 @@ /* - * $Id: urn.c,v 1.2.2.4 2000/12/20 12:41:22 adri Exp $ + * $Id: urn.c,v 1.2.2.5 2001/01/05 15:33:11 adri Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -136,7 +136,8 @@ } httpHeaderPutStr(&urlres_r->header, HDR_ACCEPT, "text/plain"); if ((urlres_e = storeGetPublic(urlres, METHOD_GET)) == NULL) { - urlres_e = storeCreateEntry(urlres, urlres, null_request_flags, METHOD_GET); + urlres_e = storeCreateEntry(urlres, urlres, null_request_flags, + METHOD_GET, REPLY_OBJ_INTERNAL); storeClientRegister(urlres_e, urnState); fwdStart(-1, urlres_e, urlres_r); } else {