--------------------- PatchSet 964 Date: 2000/12/19 12:53:04 Author: adri Branch: modio Tag: (none) Log: more tidyups: * the STR functions are moved into the StoreEntry and out of the MemObject * reply_internal_clientnomoretosend() has been slightly lobotomised to remove the backing-store-awareness (which isn't applicable now..) * Don't forceibly set the cache key to private now, it doesn't matter * storeUnlockObject() has been changed to call storeRelease() when the refcount hits 0, rather than marking the client "not in memory" and scraping clean the MemObject * storeRelease() has been severely lobotomized - all of the code dealing with a possible swapfile has been deleted Notes: * the swap size counters are probably now very invalid, but since we're not swapping out, its ok * storeRelease() is designed to delete an object from the cache, rather than a generic "we're finished". Its use by storeUnlockObject() is incorrect but its the cleanest way to implement/test the proxy only code. Once the code has been tidied up a little more this abuse will go away and storeRelease() will go back to meaning its usual thing. Members: src/reply_internal.c:1.1.2.1->1.1.2.2 src/store.c:1.2.2.6->1.2.2.7 src/store_client.c:1.2.2.4->1.2.2.5 src/structs.h:1.2.2.5->1.2.2.6 Index: squid/src/reply_internal.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/reply_internal.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/reply_internal.c 18 Dec 2000 19:10:58 -0000 1.1.2.1 +++ squid/src/reply_internal.c 19 Dec 2000 12:53:04 -0000 1.1.2.2 @@ -41,8 +41,7 @@ static void reply_internal_done(StoreEntry *e) { - MemObject *mem = e->mem_obj; - reply_internal_state_t *state = mem->stdata; + reply_internal_state_t *state = e->stdata; /* Make sure noone is left ! */ @@ -60,7 +59,7 @@ static off_t reply_internal_memhi(const StoreEntry *e) { - reply_internal_state_t *state = e->mem_obj->stdata; + reply_internal_state_t *state = e->stdata; return state->inmem_hi; } @@ -72,7 +71,7 @@ static off_t reply_internal_memlo(const StoreEntry *e) { - reply_internal_state_t *state = e->mem_obj->stdata; + reply_internal_state_t *state = e->stdata; return state->inmem_lo; } @@ -85,7 +84,7 @@ reply_internal_append(StoreEntry *e, const char *buf, int len) { MemObject *mem = e->mem_obj; - reply_internal_state_t *state = mem->stdata; + reply_internal_state_t *state = e->stdata; assert(mem != NULL); assert(len >= 0); assert(e->store_status == STORE_PENDING); @@ -100,7 +99,7 @@ } if (EBIT_TEST(e->flags, DELAY_SENDING)) return; - mem->stflush(e); + e->stflush(e); } @@ -196,20 +195,17 @@ * This function is used below to decide if we have any more data to * send to the client. If the store_status is STORE_PENDING, then we * do have more data to send. If its STORE_OK, then - * we continue checking. If the object length is negative, then we - * don't know the real length and must open the swap file to find out. + * we continue checking. * If the length is >= 0, then we compare it to the requested copy * offset. */ static int reply_internal_clientnomoretosend(StoreEntry * e, store_client * sc) { - ssize_t len; if (e->store_status == STORE_PENDING) return 0; - if ((len = objectLen(e)) < 0) - return 0; - if (sc->copy_offset < len) + assert(objectLen(e) > -1); /* Internal objects will never be swap backed */ + if (sc->copy_offset < objectLen(e)) return 0; return 1; } @@ -248,8 +244,7 @@ static void reply_internal_clientcopy3(StoreEntry * e, store_client * sc) { - MemObject *mem = e->mem_obj; - reply_internal_state_t *state = mem->stdata; + reply_internal_state_t *state = e->stdata; size_t sz; if (reply_internal_clientnomoretosend(e, sc)) { @@ -299,15 +294,15 @@ state = memPoolAlloc(reply_internal_state_pool); /* Initialise it */ - mem->stdata = state; + e->stdata = state; /* Assign our functions .. */ - mem->stappend = reply_internal_append; - mem->stflush = reply_internal_flush; - mem->stmemhi = reply_internal_memhi; - mem->stmemlo = reply_internal_memlo; - mem->stclientcopy = reply_internal_clientcopy; - mem->stdone = reply_internal_done; + e->stappend = reply_internal_append; + e->stflush = reply_internal_flush; + e->stmemhi = reply_internal_memhi; + e->stmemlo = reply_internal_memlo; + e->stclientcopy = reply_internal_clientcopy; + e->stdone = reply_internal_done; /* Done! */ } Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.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.c 18 Dec 2000 22:14:49 -0000 1.2.2.6 +++ squid/src/store.c 19 Dec 2000 12:53:04 -0000 1.2.2.7 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.2.2.6 2000/12/18 22:14:49 adri Exp $ + * $Id: store.c,v 1.2.2.7 2000/12/19 12:53:04 adri Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -179,6 +179,8 @@ destroy_MemObject(e); storeHashDelete(e); assert(e->hash.key == NULL); + + /* This is where we'd call the reply object "done" func to deallocate */ memFree(e, MEM_STOREENTRY); } @@ -291,25 +293,16 @@ storeKeyText(e->hash.key), e->lock_count); if (e->lock_count) return (int) e->lock_count; - if (e->store_status == STORE_PENDING) + + /* If the object is still pending data, we set RELEASE_REQUEST and wait */ + if (e->store_status == STORE_PENDING) { EBIT_SET(e->flags, RELEASE_REQUEST); - assert(storePendingNClients(e) == 0); - if (EBIT_TEST(e->flags, RELEASE_REQUEST)) - storeRelease(e); -#if 0 - else if (storeKeepInMemory(e)) { - storeEntryDereferenced(e); - storeSetMemStatus(e, IN_MEMORY); - requestUnlink(e->mem_obj->request); - e->mem_obj->request = NULL; - } else { -#endif - else { - storePurgeMem(e); - storeEntryDereferenced(e); - if (EBIT_TEST(e->flags, KEY_PRIVATE)) - debug(20, 1) ("WARNING: %s:%d: found KEY_PRIVATE\n", __FILE__, __LINE__); + return 0; } + + /* The object is not pending data, so kill it .. */ + assert(storePendingNClients(e) == 0); + storeRelease(e); return 0; } @@ -417,7 +410,6 @@ mem = e->mem_obj; mem->method = method; -#if 0 if (neighbors_do_private_keys || !flags.hierarchical) storeSetPrivateKey(e); else @@ -429,11 +421,7 @@ EBIT_CLR(e->flags, ENTRY_CACHABLE); storeReleaseRequest(e); } -#endif - /* All StoreEntry's are private now! */ - storeSetPrivateKey(e); - e->store_status = STORE_PENDING; storeSetMemStatus(e, NOT_IN_MEMORY); e->swap_status = SWAPOUT_NONE; @@ -459,9 +447,7 @@ void storeAppend(StoreEntry * e, const char *buf, int len) { - MemObject *mem = e->mem_obj; - - mem->stappend(e, buf, len); + e->stappend(e, buf, len); } void @@ -730,9 +716,6 @@ debug(20, 3) (" %6d were released\n", released); } -/* The maximum objects to scan for maintain storage space */ -#define MAINTAIN_MAX_SCAN 1024 -#define MAINTAIN_MAX_REMOVE 64 /* * This routine is to be called by main loop in main.c. @@ -783,38 +766,11 @@ storeReleaseRequest(e); return; } - if (store_dirs_rebuilding && e->swap_filen > -1) { - storeSetPrivateKey(e); - if (e->mem_obj) { - storeSetMemStatus(e, NOT_IN_MEMORY); - destroy_MemObject(e); - } - if (e->swap_filen > -1) { - /* - * Fake a call to storeLockObject(). When rebuilding is done, - * we'll just call storeUnlockObject() on these. - */ - e->lock_count++; - EBIT_SET(e->flags, RELEASE_REQUEST); - stackPush(&LateReleaseStack, e); - return; - } else { - destroy_StoreEntry(e); - } - } + + /* Time to deallocate the storeentry .. */ storeLog(STORE_LOG_RELEASE, e); - if (e->swap_filen > -1) { - storeUnlink(e); - if (e->swap_status == SWAPOUT_DONE) - if (EBIT_TEST(e->flags, ENTRY_VALIDATED)) - storeDirUpdateSwapSize(&Config.cacheSwap.swapDirs[e->swap_dirn], e->swap_file_sz, -1); - if (!EBIT_TEST(e->flags, KEY_PRIVATE)) - storeDirSwapLog(e, SWAP_LOG_DEL); -#if 0 - /* From 2.4. I think we do this in storeUnlink? */ - storeSwapFileNumberSet(e, -1); -#endif - } + + /* Here we'd log a swap log delete, but thats done at the FS layer .. */ storeSetMemStatus(e, NOT_IN_MEMORY); destroy_StoreEntry(e); } @@ -848,16 +804,6 @@ { if (e->lock_count) return 1; - if (e->swap_status == SWAPOUT_WRITING) - return 1; - if (e->store_status == STORE_PENDING) - return 1; - /* - * SPECIAL, PUBLIC entries should be "locked" - */ - if (EBIT_TEST(e->flags, ENTRY_SPECIAL)) - if (!EBIT_TEST(e->flags, KEY_PRIVATE)) - return 1; return 0; } @@ -1282,14 +1228,14 @@ storeMemHiOffset(const StoreEntry *e) { assert(e->mem_obj != NULL); - return e->mem_obj->stmemhi(e); + return e->stmemhi(e); } off_t storeMemLoOffset(const StoreEntry *e) { assert(e->mem_obj != NULL); - return e->mem_obj->stmemlo(e); + return e->stmemlo(e); } #if 0 @@ -1324,26 +1270,22 @@ STRMEMHI *stmemhi, STRMEMLO *stmemlo, STRCLIENTCOPY *stclientcopy, STRDONE *stdone, void *stdata) { - MemObject *mem; - assert (e != NULL); assert (e->mem_obj != NULL); - mem = e->mem_obj; - /* If we have a reply attached already, call its done handler .. */ - if (mem->stdone != NULL) { + if (e->stdone != NULL) { storeDetachReply(e); } /* Attach the reply */ - mem->stappend = stappend; - mem->stflush = stflush; - mem->stmemhi = stmemhi; - mem->stmemlo = stmemlo; - mem->stclientcopy = stclientcopy; - mem->stdone = stdone; - mem->stdata = stdata; + e->stappend = stappend; + e->stflush = stflush; + e->stmemhi = stmemhi; + e->stmemlo = stmemlo; + e->stclientcopy = stclientcopy; + e->stdone = stdone; + e->stdata = stdata; /* .. and done! */ } @@ -1355,25 +1297,23 @@ void storeDetachReply(StoreEntry *e) { - MemObject *mem; STRDONE *stdone; assert (e != NULL); assert (e->mem_obj != NULL); - mem = e->mem_obj; - stdone = mem->stdone; + stdone = e->stdone; if (stdone == NULL) return; stdone(e); - mem->stappend = NULL; - mem->stflush = NULL; - mem->stmemhi = NULL; - mem->stmemlo = NULL; - mem->stclientcopy = NULL; - mem->stdone = NULL; - mem->stdata = NULL; + e->stappend = NULL; + e->stflush = NULL; + e->stmemhi = NULL; + e->stmemlo = NULL; + e->stclientcopy = NULL; + e->stdone = NULL; + e->stdata = NULL; } Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.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/store_client.c 18 Dec 2000 22:14:49 -0000 1.2.2.4 +++ squid/src/store_client.c 19 Dec 2000 12:53:04 -0000 1.2.2.5 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.2.2.4 2000/12/18 22:14:49 adri Exp $ + * $Id: store_client.c,v 1.2.2.5 2000/12/19 12:53:04 adri Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -131,7 +131,7 @@ { assert(!EBIT_TEST(e->flags, ENTRY_ABORTED)); assert(sc != NULL); - e->mem_obj->stclientcopy(sc, e, seen_offset, copy_offset, size, buf, + e->stclientcopy(sc, e, seen_offset, copy_offset, size, buf, callback, data); } @@ -379,10 +379,9 @@ void InvokeHandlers(StoreEntry * e) { - MemObject *mem = e->mem_obj; - + assert(e->mem_obj != NULL); debug(20, 3) ("InvokeHandlers: %s\n", storeKeyText(e->hash.key)); - mem->stflush(e); + e->stflush(e); } int Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.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/structs.h 18 Dec 2000 22:14:49 -0000 1.2.2.5 +++ squid/src/structs.h 19 Dec 2000 12:53:04 -0000 1.2.2.6 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.2.2.5 2000/12/18 22:14:49 adri Exp $ + * $Id: structs.h,v 1.2.2.6 2000/12/19 12:53:04 adri Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1306,15 +1306,6 @@ #if URL_CHECKSUM_DEBUG unsigned int chksum; #endif - - /* The reply callback functions */ - STRAPPEND *stappend; - STRFLUSH *stflush; - STRMEMHI *stmemhi; - STRMEMLO *stmemlo; - STRCLIENTCOPY *stclientcopy; - STRDONE *stdone; - void *stdata; }; struct _StoreEntry { @@ -1335,6 +1326,15 @@ ping_status_t ping_status:3; store_status_t store_status:3; swap_status_t swap_status:3; + + /* The reply callback functions */ + STRAPPEND *stappend; + STRFLUSH *stflush; + STRMEMHI *stmemhi; + STRMEMLO *stmemlo; + STRCLIENTCOPY *stclientcopy; + STRDONE *stdone; + void *stdata; }; struct _SwapDir {