--------------------- PatchSet 967 Date: 2000/12/20 11:48:41 Author: adri Branch: modio Tag: (none) Log: remove all references to the store_client struct outside of the StoreEntry. This involves removing the store_client parameter from a bunch of routines in src/store_client.c, since we just need a StoreEntry now.. Members: src/asn.c:1.2.2.4->1.2.2.5 src/client_side.c:1.2.2.5->1.2.2.6 src/protos.h:1.2.2.5->1.2.2.6 src/pump.c:1.2.2.2->1.2.2.3 src/store_client.c:1.2.2.6->1.2.2.7 src/structs.h:1.2.2.7->1.2.2.8 src/urn.c:1.2.2.2->1.2.2.3 Index: squid/src/asn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/asn.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/asn.c 18 Dec 2000 12:39:35 -0000 1.2.2.4 +++ squid/src/asn.c 20 Dec 2000 11:48:41 -0000 1.2.2.5 @@ -1,6 +1,6 @@ /* - * $Id: asn.c,v 1.2.2.4 2000/12/18 12:39:35 adri Exp $ + * $Id: asn.c,v 1.2.2.5 2000/12/20 11:48:41 adri Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -197,17 +197,16 @@ asState->request = requestLink(req); if ((e = storeGetPublic(asres, METHOD_GET)) == NULL) { e = storeCreateEntry(asres, asres, null_request_flags, METHOD_GET); - asState->sc = storeClientListAdd(e, asState); + storeClientListAdd(e, asState); fwdStart(-1, e, asState->request); } else { storeLockObject(e); - asState->sc = storeClientListAdd(e, asState); + storeClientListAdd(e, asState); } asState->entry = e; asState->seen = 0; asState->offset = 0; - storeClientCopy(asState->sc, - e, + storeClientCopy(e, asState->seen, asState->offset, 4096, @@ -268,8 +267,7 @@ asState->seen, asState->offset); if (e->store_status == STORE_PENDING) { debug(53, 3) ("asHandleReply: store_status == STORE_PENDING: %s\n", storeUrl(e)); - storeClientCopy(asState->sc, - e, + storeClientCopy(e, asState->seen, asState->offset, SM_PAGE_SIZE, @@ -278,8 +276,7 @@ asState); } else if (asState->seen < storeMemHiOffset(e)) { debug(53, 3) ("asHandleReply: asState->seen < storeMemHiOffset(e) %s\n", storeUrl(e)); - storeClientCopy(asState->sc, - e, + storeClientCopy(e, asState->seen, asState->offset, SM_PAGE_SIZE, @@ -298,7 +295,7 @@ { ASState *asState = data; debug(53, 3) ("asnStateFree: %s\n", storeUrl(asState->entry)); - storeUnregister(asState->sc, asState->entry, asState); + storeUnregister(asState->entry, asState); storeUnlockObject(asState->entry); requestUnlink(asState->request); cbdataFree(asState); Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.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/client_side.c 18 Dec 2000 19:10:58 -0000 1.2.2.5 +++ squid/src/client_side.c 20 Dec 2000 11:48:41 -0000 1.2.2.6 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.2.2.5 2000/12/18 19:10:58 adri Exp $ + * $Id: client_side.c,v 1.2.2.6 2000/12/20 11:48:41 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -201,11 +201,11 @@ e = storeCreateEntry(h->uri, h->log_uri, flags, m); /* XXX just for testing! */ reply_internal_create(e); - h->sc = storeClientListAdd(e, h); + storeClientListAdd(e, h); #if DELAY_POOLS delaySetStoreClient(h->sc, delayClient(h->request)); #endif - storeClientCopy(h->sc, e, 0, 0, CLIENT_SOCK_SZ, + storeClientCopy(e, 0, 0, CLIENT_SOCK_SZ, memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, h); return e; } @@ -364,19 +364,18 @@ } http->request->flags.refresh = 1; http->old_entry = http->entry; - http->old_sc = http->sc; /* * Assert that 'http' is already a client of old_entry. If * it is not, then the beginning of the object data might get * freed from memory before we need to access it. */ - assert(http->sc->callback_data == http); + assert(http->entry->sc.callback_data == http); entry = storeCreateEntry(url, http->log_uri, http->request->flags, http->request->method); /* NOTE, don't call storeLockObject(), storeCreateEntry() does it */ - http->sc = storeClientListAdd(entry, http); + storeClientListAdd(entry, http); #if DELAY_POOLS /* delay_id is already set on original store client */ delaySetStoreClient(http->sc, delayClient(http->request)); @@ -389,7 +388,7 @@ /* Register with storage manager to receive updates when data comes in. */ if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) debug(33, 0) ("clientProcessExpired: found ENTRY_ABORTED object\n"); - storeClientCopy(http->sc, entry, + storeClientCopy(entry, http->out.offset, http->out.offset, CLIENT_SOCK_SZ, @@ -463,10 +462,9 @@ /* We have an existing entry, but failed to validate it */ /* Its okay to send the old one anyway */ http->log_type = LOG_TCP_REFRESH_FAIL_HIT; - storeUnregister(http->sc, entry, http); + storeUnregister(entry, http); storeUnlockObject(entry); entry = http->entry = http->old_entry; - http->sc = http->old_sc; } else if (STORE_PENDING == entry->store_status && 0 == status) { debug(33, 3) ("clientHandleIMSReply: Incomplete headers for '%s'\n", url); if (size >= CLIENT_SOCK_SZ) { @@ -474,13 +472,12 @@ debug(33, 3) ("clientHandleIMSReply: Reply is too large '%s', using old entry\n", url); /* use old entry, this repeats the code abovez */ http->log_type = LOG_TCP_REFRESH_FAIL_HIT; - storeUnregister(http->sc, entry, http); + storeUnregister(entry, http); storeUnlockObject(entry); entry = http->entry = http->old_entry; - http->sc = http->old_sc; /* continue */ } else { - storeClientCopy(http->sc, entry, + storeClientCopy(entry, http->out.offset + size, http->out.offset, CLIENT_SOCK_SZ, @@ -505,8 +502,7 @@ * not the body they refer to. */ httpReplyUpdateOnNotModified(oldentry->mem_obj->reply, mem->reply); storeTimestampsSet(oldentry); - storeUnregister(http->sc, entry, http); - http->sc = http->old_sc; + storeUnregister(entry, http); storeUnlockObject(entry); entry = http->entry = oldentry; entry->timestamp = squid_curtime; @@ -523,15 +519,14 @@ storeTimestampsSet(http->old_entry); http->log_type = LOG_TCP_REFRESH_HIT; } - storeUnregister(http->old_sc, http->old_entry, http); + storeUnregister(http->old_entry, http); storeUnlockObject(http->old_entry); recopy = 0; } http->old_entry = NULL; /* done with old_entry */ - http->old_sc = NULL; assert(!EBIT_TEST(entry->flags, ENTRY_ABORTED)); if (recopy) { - storeClientCopy(http->sc, entry, + storeClientCopy(entry, http->out.offset, http->out.offset, CLIENT_SOCK_SZ, @@ -713,7 +708,7 @@ */ if ((e = http->entry)) { http->entry = NULL; - storeUnregister(http->sc, e, http); + storeUnregister(e, http); storeUnlockObject(e); } #endif @@ -768,16 +763,14 @@ stringClean(&http->range_iter.boundary); if ((e = http->entry)) { http->entry = NULL; - storeUnregister(http->sc, e, http); - http->sc = NULL; + storeUnregister(e, http); storeUnlockObject(e); } /* old_entry might still be set if we didn't yet get the reply * code in clientHandleIMSReply() */ if ((e = http->old_entry)) { http->old_entry = NULL; - storeUnregister(http->old_sc, e, http); - http->old_sc = NULL; + storeUnregister(e, http); storeUnlockObject(e); } requestUnlink(http->request); @@ -1354,8 +1347,7 @@ http->log_type = LOG_TCP_SWAPFAIL_MISS; if ((e = http->entry)) { http->entry = NULL; - storeUnregister(http->sc, e, http); - http->sc = NULL; + storeUnregister(e, http); storeUnlockObject(e); } clientProcessMiss(http); @@ -1377,7 +1369,7 @@ clientProcessMiss(http); } else { debug(33, 3) ("clientCacheHit: waiting for HTTP reply headers\n"); - storeClientCopy(http->sc, e, + storeClientCopy(e, http->out.offset + size, http->out.offset, CLIENT_SOCK_SZ, @@ -1464,8 +1456,7 @@ MemBuf mb = httpPacked304Reply(e->mem_obj->reply); http->log_type = LOG_TCP_IMS_HIT; memFree(buf, MEM_CLIENT_SOCK_BUF); - storeUnregister(http->sc, e, http); - http->sc = NULL; + storeUnregister(e, http); storeUnlockObject(e); e = clientCreateStoreEntry(http, http->request->method, null_request_flags); /* @@ -1735,8 +1726,7 @@ if (rep && clientReplyBodyTooLarge(rep->content_length)) { ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_FORBIDDEN); err->request = requestLink(http->request); - storeUnregister(http->sc, http->entry, http); - http->sc = NULL; + storeUnregister(http->entry, http); storeUnlockObject(http->entry); http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); @@ -1752,7 +1742,7 @@ body_size, rep->hdr_sz); } else if (size < CLIENT_SOCK_SZ && entry->store_status == STORE_PENDING) { /* wait for more to arrive */ - storeClientCopy(http->sc, entry, + storeClientCopy(entry, http->out.offset + size, http->out.offset, CLIENT_SOCK_SZ, @@ -1880,10 +1870,10 @@ debug(33, 1) ("clientKeepaliveNextRequest: FD %d Sending next\n", conn->fd); assert(entry); - if (0 == storeClientCopyPending(http->sc, entry, http)) { + if (0 == storeClientCopyPending(entry, http)) { if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) debug(33, 0) ("clientKeepaliveNextRequest: ENTRY_ABORTED\n"); - storeClientCopy(http->sc, entry, + storeClientCopy(entry, http->out.offset, http->out.offset, CLIENT_SOCK_SZ, @@ -1942,7 +1932,7 @@ * storage manager. */ if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) debug(33, 0) ("clientWriteComplete 2: ENTRY_ABORTED\n"); - storeClientCopy(http->sc, entry, + storeClientCopy(entry, http->out.offset, http->out.offset, CLIENT_SOCK_SZ, @@ -1971,8 +1961,7 @@ err->request = requestLink(r); err->src_addr = http->conn->peer.sin_addr; if (http->entry) { - storeUnregister(http->sc, http->entry, http); - http->sc = NULL; + storeUnregister(http->entry, http); storeUnlockObject(http->entry); } http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); @@ -2152,11 +2141,11 @@ storeLockObject(http->entry); storeCreateMemObject(http->entry, http->uri, http->log_uri); http->entry->mem_obj->method = r->method; - http->sc = storeClientListAdd(http->entry, http); + storeClientListAdd(http->entry, http); #if DELAY_POOLS delaySetStoreClient(http->sc, delayClient(r)); #endif - storeClientCopy(http->sc, http->entry, + storeClientCopy(http->entry, http->out.offset, http->out.offset, CLIENT_SOCK_SZ, @@ -2190,8 +2179,7 @@ debug(33, 0) ("\tlog_type = %s\n", log_tags[http->log_type]); storeEntryDump(http->entry, 1); } - storeUnregister(http->sc, http->entry, http); - http->sc = NULL; + storeUnregister(http->entry, http); storeUnlockObject(http->entry); http->entry = NULL; } Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,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/protos.h 18 Dec 2000 19:10:58 -0000 1.2.2.5 +++ squid/src/protos.h 20 Dec 2000 11:48:41 -0000 1.2.2.6 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.2.2.5 2000/12/18 19:10:58 adri Exp $ + * $Id: protos.h,v 1.2.2.6 2000/12/20 11:48:41 adri Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -976,10 +976,10 @@ #if STORE_CLIENT_LIST_DEBUG extern store_client *storeClientListSearch(const MemObject * mem, void *data); #endif -extern store_client *storeClientListAdd(StoreEntry * e, void *data); -extern void storeClientCopy(store_client *, StoreEntry *, off_t, off_t, size_t, char *, STCB *, void *); -extern int storeClientCopyPending(store_client *, StoreEntry * e, void *data); -extern int storeUnregister(store_client * sc, StoreEntry * e, void *data); +extern void storeClientListAdd(StoreEntry * e, void *data); +extern void storeClientCopy(StoreEntry *, off_t, off_t, size_t, char *, STCB *, void *); +extern int storeClientCopyPending(StoreEntry * e, void *data); +extern int storeUnregister(StoreEntry * e, void *data); extern off_t storeLowestMemReaderOffset(const StoreEntry * entry); extern void InvokeHandlers(StoreEntry * e); extern int storePendingNClients(const StoreEntry * e); Index: squid/src/pump.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/pump.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/pump.c 13 Dec 2000 09:45:03 -0000 1.2.2.2 +++ squid/src/pump.c 20 Dec 2000 11:48:41 -0000 1.2.2.3 @@ -1,6 +1,6 @@ /* - * $Id: pump.c,v 1.2.2.2 2000/12/13 09:45:03 rbcollins Exp $ + * $Id: pump.c,v 1.2.2.3 2000/12/20 11:48:41 adri Exp $ * * DEBUG: section 61 PUMP handler * AUTHOR: Kostas Anagnostakis @@ -72,7 +72,7 @@ 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->sc = storeClientListAdd(p->request_entry, p); + storeClientListAdd(p->request_entry, p); EBIT_SET(p->request_entry->flags, ENTRY_DONT_LOG); #if DELAY_POOLS delaySetStoreClient(p->sc, delayClient(r)); @@ -144,7 +144,7 @@ if (p->sent == p->req->content_length) { pumpServerCopyComplete(p->s_fd, NULL, 0, DISK_OK, p); } else { - storeClientCopy(p->sc, p->request_entry, p->sent, p->sent, 4096, + storeClientCopy(p->request_entry, p->sent, p->sent, 4096, memAllocate(MEM_4K_BUF), pumpServerCopy, p); } @@ -192,7 +192,7 @@ p->sent += size; assert(p->sent <= p->req->content_length); if (p->sent < p->req->content_length) { - storeClientCopy(p->sc, p->request_entry, p->sent, p->sent, 4096, + storeClientCopy(p->request_entry, p->sent, p->sent, 4096, memAllocate(MEM_4K_BUF), pumpServerCopy, p); return; @@ -307,7 +307,7 @@ assert(!p->flags.closing); p->flags.closing = 1; if (req != NULL && req->store_status == STORE_PENDING) { - storeUnregister(p->sc, req, p); + storeUnregister(req, p); } if (rep != NULL && rep->store_status == STORE_PENDING) { ErrorState *err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR); @@ -347,7 +347,7 @@ req = p->request_entry; rep = p->reply_entry; if (req != NULL) { - storeUnregister(p->sc, req, p); + storeUnregister(req, p); storeUnlockObject(req); p->request_entry = NULL; } Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.c,v retrieving revision 1.2.2.6 retrieving revision 1.2.2.7 diff -u -r1.2.2.6 -r1.2.2.7 --- squid/src/store_client.c 19 Dec 2000 15:27:28 -0000 1.2.2.6 +++ squid/src/store_client.c 20 Dec 2000 11:48:41 -0000 1.2.2.7 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.2.2.6 2000/12/19 15:27:28 adri Exp $ + * $Id: store_client.c,v 1.2.2.7 2000/12/20 11:48:41 adri Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -60,7 +60,7 @@ /* add client with fd to client list */ -store_client * +void storeClientListAdd(StoreEntry * e, void *data) { e->refcount++; @@ -79,25 +79,24 @@ #if DELAY_POOLS e->sc.delay_id = 0; #endif - return &e->sc; } static void -storeClientCallback(store_client * sc, ssize_t sz) +storeClientCallback(StoreEntry *e, ssize_t sz) { - STCB *callback = sc->callback; - char *buf = sc->copy_buf; - assert(sc->callback); - sc->callback = NULL; - sc->copy_buf = NULL; - if (cbdataValid(sc->callback_data)) - callback(sc->callback_data, buf, sz); + STCB *callback = e->sc.callback; + char *buf = e->sc.copy_buf; + assert(e->sc.valid == 1); + assert(e->sc.callback); + e->sc.callback = NULL; + e->sc.copy_buf = NULL; + if (cbdataValid(e->sc.callback_data)) + callback(e->sc.callback_data, buf, sz); } /* copy bytes requested by the client */ void -storeClientCopy(store_client * sc, - StoreEntry * e, +storeClientCopy(StoreEntry * e, off_t seen_offset, off_t copy_offset, size_t size, @@ -105,11 +104,11 @@ STCB * callback, void *data) { + store_client *sc = &e->sc; assert(!EBIT_TEST(e->flags, ENTRY_ABORTED)); - assert(sc != NULL); assert(!EBIT_TEST(e->flags, ENTRY_ABORTED)); - assert(sc == &e->sc); + assert(sc->valid == 1); debug(20, 3) ("storeClientCopy: %s, seen %d, want %d, size %d, cb %p, cbdata %p\n", storeKeyText(e->hash.key), (int) seen_offset, (int) copy_offset, @@ -131,12 +130,9 @@ int -storeClientCopyPending(store_client * sc, StoreEntry * e, void *data) +storeClientCopyPending(StoreEntry * e, void *data) { - assert(sc->entry == e); - if (sc == NULL) - return 0; - if (sc->callback == NULL) + if (e->sc.callback == NULL) return 0; return 1; } @@ -296,8 +292,9 @@ * Disassociate a client from a storeentry */ int -storeUnregister(store_client * sc, StoreEntry * e, void *data) +storeUnregister(StoreEntry * e, void *data) { + store_client *sc = &e->sc; MemObject *mem = e->mem_obj; debug(20, 3) ("storeUnregister: called for '%s'\n", storeKeyText(e->hash.key)); @@ -316,7 +313,7 @@ /* callback with ssize = -1 to indicate unexpected termination */ debug(20, 3) ("storeUnregister: store_client for %s has a callback\n", mem->url); - storeClientCallback(sc, -1); + storeClientCallback(e, -1); } #if DELAY_POOLS delayUnregisterDelayIdPtr(&sc->delay_id); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,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/structs.h 19 Dec 2000 15:27:29 -0000 1.2.2.7 +++ squid/src/structs.h 20 Dec 2000 11:48:42 -0000 1.2.2.8 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.2.2.7 2000/12/19 15:27:29 adri Exp $ + * $Id: structs.h,v 1.2.2.8 2000/12/20 11:48:42 adri Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -873,8 +873,6 @@ struct _clientHttpRequest { ConnStateData *conn; request_t *request; /* Parsed URL ... */ - store_client *sc; /* The store_client we're using */ - store_client *old_sc; /* ... for entry to be validated */ char *uri; char *log_uri; struct { @@ -970,8 +968,6 @@ PeerDigest *pd; StoreEntry *entry; StoreEntry *old_entry; - store_client *sc; - store_client *old_sc; request_t *request; int offset; int mask_offset; @@ -1862,7 +1858,6 @@ struct _PumpStateData { FwdState *fwd; request_t *req; - store_client *sc; /* The store client we're using */ int c_fd; /* client fd */ int s_fd; /* server end */ int rcvd; /* bytes received from client */ Index: squid/src/urn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/urn.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/urn.c 13 Dec 2000 07:57:55 -0000 1.2.2.2 +++ squid/src/urn.c 20 Dec 2000 11:48:42 -0000 1.2.2.3 @@ -1,6 +1,6 @@ /* - * $Id: urn.c,v 1.2.2.2 2000/12/13 07:57:55 adri Exp $ + * $Id: urn.c,v 1.2.2.3 2000/12/20 11:48:42 adri Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -137,15 +137,15 @@ 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); - urnState->sc = storeClientListAdd(urlres_e, urnState); + storeClientListAdd(urlres_e, urnState); fwdStart(-1, urlres_e, urlres_r); } else { storeLockObject(urlres_e); - urnState->sc = storeClientListAdd(urlres_e, urnState); + storeClientListAdd(urlres_e, urnState); } urnState->urlres_e = urlres_e; urnState->urlres_r = requestLink(urlres_r); - storeClientCopy(urnState->sc, urlres_e, + storeClientCopy(urlres_e, 0, 0, 4096, @@ -200,7 +200,7 @@ return; } if (urlres_e->store_status == STORE_PENDING && size < SM_PAGE_SIZE) { - storeClientCopy(urnState->sc, urlres_e, + storeClientCopy(urlres_e, size, 0, SM_PAGE_SIZE, @@ -291,7 +291,7 @@ } safe_free(urls); /* mb was absorbed in httpBodySet call, so we must not clean it */ - storeUnregister(urnState->sc, urlres_e, urnState); + storeUnregister(urlres_e, urnState); storeUnlockObject(urlres_e); storeUnlockObject(urnState->entry); requestUnlink(urnState->request);