From: wessels <> Date: Wed, 18 Apr 2007 05:05:17 +0000 (+0000) Subject: Converted three store_swapout.cc functions to StoreEntry class methods X-Git-Tag: SQUID_3_0_PRE6~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c07cbbf4b8035c2fc0489b57da12947dbd86be87;p=thirdparty%2Fsquid.git Converted three store_swapout.cc functions to StoreEntry class methods storeSwapOut() is now StoreEntry::swapOut() storeSwapOutFileClose() is now StoreEntry::swapOutFileClose() storeSwapOutAble() is now Storeentry::swapOutAble() --- diff --git a/src/Store.h b/src/Store.h index adef419426..ddf30d49eb 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.28 2007/04/17 06:07:50 wessels Exp $ + * $Id: Store.h,v 1.29 2007/04/17 23:05:17 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -84,6 +84,9 @@ public: void makePublic(); void makePrivate(); void cacheNegatively(); + void swapOut(); + bool swapOutAble() const; + void swapOutFileClose(); void delayAwareRead(int fd, char *buf, int len, IOCB *handler, void *data); diff --git a/src/protos.h b/src/protos.h index fc9785d6d9..c692949ae3 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.540 2007/04/15 14:46:17 serassio Exp $ + * $Id: protos.h,v 1.541 2007/04/17 23:05:17 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -564,13 +564,6 @@ SQUIDCEXTERN void storeRebuildProgress(int sd_index, int total, int sofar); */ SQUIDCEXTERN void storeSwapInStart(store_client *); -/* - * store_swapout.c - */ -SQUIDCEXTERN void storeSwapOut(StoreEntry * e); -SQUIDCEXTERN void storeSwapOutFileClose(StoreEntry * e); -SQUIDCEXTERN int storeSwapOutAble(const StoreEntry * e); - /* * store_client.c */ diff --git a/src/store.cc b/src/store.cc index 4198ae92ed..1636fac750 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.605 2007/04/17 06:07:50 wessels Exp $ + * $Id: store.cc,v 1.606 2007/04/17 23:05:17 wessels Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -1163,7 +1163,7 @@ storeAbort(StoreEntry * e) InvokeHandlers(e); /* Close any swapout file */ - storeSwapOutFileClose(e); + e->swapOutFileClose(); e->unlock(); /* unlock */ } @@ -1879,7 +1879,7 @@ StoreEntry::swapoutPossible() if (EBIT_TEST(flags, ENTRY_ABORTED)) { assert(EBIT_TEST(flags, RELEASE_REQUEST)); - storeSwapOutFileClose(this); + swapOutFileClose(); return false; } @@ -1900,7 +1900,7 @@ StoreEntry::trimMemory() assert (mem_obj->policyLowestOffsetToKeep() > 0); - if (!storeSwapOutAble(this)) { + if (!swapOutAble()) { /* * Its not swap-able, and we're about to delete a chunk, * so we must make it PRIVATE. This is tricky/ugly because diff --git a/src/store_client.cc b/src/store_client.cc index 9c2172f458..5c914c9e76 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.149 2007/04/17 05:40:18 wessels Exp $ + * $Id: store_client.cc,v 1.150 2007/04/17 23:05:17 wessels Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -194,7 +194,7 @@ store_client::store_client(StoreEntry *e) : entry (e) if (getType() == STORE_DISK_CLIENT) /* assert we'll be able to get the data we want */ /* maybe we should open swapin_fd here */ - assert(entry->swap_filen > -1 || storeSwapOutAble(entry)); + assert(entry->swap_filen > -1 || entry->swapOutAble()); #if STORE_CLIENT_LIST_DEBUG @@ -666,7 +666,7 @@ storeUnregister(store_client * sc, StoreEntry * e, void *data) mem->nclients--; if (e->store_status == STORE_OK && e->swap_status != SWAPOUT_DONE) - storeSwapOut(e); + e->swapOut(); if (sc->swapin_sio.getRaw()) { storeClose(sc->swapin_sio); @@ -709,7 +709,7 @@ void InvokeHandlers(StoreEntry * e) { /* Commit what we can to disk, if appropriate */ - storeSwapOut (e); + e->swapOut(); int i = 0; MemObject *mem = e->mem_obj; store_client *sc; diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 55e89912fa..2774313010 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.cc,v 1.109 2007/04/17 05:40:18 wessels Exp $ + * $Id: store_swapout.cc,v 1.110 2007/04/17 23:05:17 wessels Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -181,34 +181,32 @@ doPages(StoreEntry *anEntry) * It's overhead is therefor, significant. */ void -storeSwapOut(StoreEntry * e) +StoreEntry::swapOut() { - if (!e->mem_obj) + if (!mem_obj) return; - if (!e->swapoutPossible()) + if (!swapoutPossible()) return; - MemObject *mem = e->mem_obj; - - debug(20, 7) ("storeSwapOut: mem->inmem_lo = %d\n", - (int) mem->inmem_lo); + debug(20, 7) ("storeSwapOut: mem_obj->inmem_lo = %d\n", + (int) mem_obj->inmem_lo); - debug(20, 7) ("storeSwapOut: mem->endOffset() = %d\n", - (int) mem->endOffset()); + debug(20, 7) ("storeSwapOut: mem_obj->endOffset() = %d\n", + (int) mem_obj->endOffset()); debug(20, 7) ("storeSwapOut: swapout.queue_offset = %d\n", - (int) mem->swapout.queue_offset); + (int) mem_obj->swapout.queue_offset); - if (mem->swapout.sio.getRaw()) + if (mem_obj->swapout.sio.getRaw()) debug(20, 7) ("storeSwapOut: storeOffset() = %d\n", - (int) mem->swapout.sio->offset()); + (int) mem_obj->swapout.sio->offset()); - ssize_t swapout_maxsize = (ssize_t) (mem->endOffset() - mem->swapout.queue_offset); + ssize_t swapout_maxsize = (ssize_t) (mem_obj->endOffset() - mem_obj->swapout.queue_offset); assert(swapout_maxsize >= 0); - off_t const lowest_offset = mem->lowestMemReaderOffset(); + off_t const lowest_offset = mem_obj->lowestMemReaderOffset(); debug(20, 7) ("storeSwapOut: lowest_offset = %d\n", (int) lowest_offset); @@ -217,7 +215,7 @@ storeSwapOut(StoreEntry * e) * Grab the swapout_size and check to see whether we're going to defer * the swapout based upon size */ - if ((e->store_status != STORE_OK) && (swapout_maxsize < store_maxobjsize)) { + if ((store_status != STORE_OK) && (swapout_maxsize < store_maxobjsize)) { /* * NOTE: the store_maxobjsize here is the max of optional * max-size values from 'cache_dir' lines. It is not the @@ -232,33 +230,33 @@ storeSwapOut(StoreEntry * e) return; } - e->trimMemory(); + trimMemory(); #if SIZEOF_OFF_T == 4 - if (mem->endOffset() > 0x7FFF0000) { + if (mem_obj->endOffset() > 0x7FFF0000) { debug(20, 0) ("WARNING: preventing off_t overflow for %s\n", storeUrl(e)); storeAbort(e); return; } #endif - if (e->swap_status == SWAPOUT_WRITING) - assert(mem->inmem_lo <= (off_t)mem->objectBytesOnDisk() ); + if (swap_status == SWAPOUT_WRITING) + assert(mem_obj->inmem_lo <= (off_t)mem_obj->objectBytesOnDisk() ); - if (!storeSwapOutAble(e)) + if (!swapOutAble()) return; debug(20, 7) ("storeSwapOut: swapout_size = %d\n", (int) swapout_maxsize); if (swapout_maxsize == 0) { - if (e->store_status == STORE_OK) - storeSwapOutFileClose(e); + if (store_status == STORE_OK) + swapOutFileClose(); return; /* Nevermore! */ } - if (e->store_status == STORE_PENDING) { + if (store_status == STORE_PENDING) { /* wait for a full block to write */ if (swapout_maxsize < SM_PAGE_SIZE) @@ -268,55 +266,54 @@ storeSwapOut(StoreEntry * e) * Wait until we are below the disk FD limit, only if the * next server-side read won't be deferred. */ - if (storeTooManyDiskFilesOpen() && !e->checkDeferRead(-1)) + if (storeTooManyDiskFilesOpen() && !checkDeferRead(-1)) return; } /* Ok, we have stuff to swap out. Is there a swapout.sio open? */ - if (e->swap_status == SWAPOUT_NONE) { - assert(mem->swapout.sio == NULL); - assert(mem->inmem_lo == 0); + if (swap_status == SWAPOUT_NONE) { + assert(mem_obj->swapout.sio == NULL); + assert(mem_obj->inmem_lo == 0); - if (storeCheckCachable(e)) - storeSwapOutStart(e); + if (storeCheckCachable(this)) + storeSwapOutStart(this); else return; /* ENTRY_CACHABLE will be cleared and we'll never get here again */ } - if (mem->swapout.sio == NULL) + if (mem_obj->swapout.sio == NULL) return; - doPages(e); + doPages(this); - if (NULL == mem->swapout.sio.getRaw()) + if (NULL == mem_obj->swapout.sio.getRaw()) /* oops, we're not swapping out any more */ return; - if (e->store_status == STORE_OK) { + if (store_status == STORE_OK) { /* * If the state is STORE_OK, then all data must have been given * to the filesystem at this point because storeSwapOut() is * not going to be called again for this entry. */ - assert(mem->endOffset() == mem->swapout.queue_offset); - storeSwapOutFileClose(e); + assert(mem_obj->endOffset() == mem_obj->swapout.queue_offset); + swapOutFileClose(); } } void -storeSwapOutFileClose(StoreEntry * e) +StoreEntry::swapOutFileClose() { - MemObject *mem = e->mem_obj; - assert(mem != NULL); - debug(20, 3) ("storeSwapOutFileClose: %s\n", e->getMD5Text()); - debug(20, 3) ("storeSwapOutFileClose: sio = %p\n", mem->swapout.sio.getRaw()); + assert(mem_obj != NULL); + debug(20, 3) ("storeSwapOutFileClose: %s\n", getMD5Text()); + debug(20, 3) ("storeSwapOutFileClose: sio = %p\n", mem_obj->swapout.sio.getRaw()); - if (mem->swapout.sio == NULL) + if (mem_obj->swapout.sio == NULL) return; - storeClose(mem->swapout.sio); + storeClose(mem_obj->swapout.sio); } static void @@ -375,16 +372,16 @@ storeSwapOutFileClosed(void *data, int errflag, StoreIOState::Pointer self) /* * Is this entry a candidate for writing to disk? */ -int -storeSwapOutAble(const StoreEntry * e) +bool +StoreEntry::swapOutAble() const { dlink_node *node; - if (e->mem_obj->swapout.sio.getRaw() != NULL) - return 1; + if (mem_obj->swapout.sio.getRaw() != NULL) + return true; - if (e->mem_obj->inmem_lo > 0) - return 0; + if (mem_obj->inmem_lo > 0) + return false; /* * If there are DISK clients, we must write to disk @@ -394,20 +391,20 @@ storeSwapOutAble(const StoreEntry * e) * RBC 20030708: We can use disk to avoid mem races, so this shouldn't be * an assert. */ - for (node = e->mem_obj->clients.head; node; node = node->next) { + for (node = mem_obj->clients.head; node; node = node->next) { if (((store_client *) node->data)->getType() == STORE_DISK_CLIENT) - return 1; + return true; } /* Don't pollute the disk with icons and other special entries */ - if (EBIT_TEST(e->flags, ENTRY_SPECIAL)) - return 0; + if (EBIT_TEST(flags, ENTRY_SPECIAL)) + return false; - if (!EBIT_TEST(e->flags, ENTRY_CACHABLE)) - return 0; + if (!EBIT_TEST(flags, ENTRY_CACHABLE)) + return false; - if (!e->mem_obj->isContiguous()) - return 0; + if (!mem_obj->isContiguous()) + return false; - return 1; + return true; } diff --git a/src/tests/stub_store_swapout.cc b/src/tests/stub_store_swapout.cc index f59d10fa13..549ba9f149 100644 --- a/src/tests/stub_store_swapout.cc +++ b/src/tests/stub_store_swapout.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_store_swapout.cc,v 1.2 2006/04/25 07:13:34 robertc Exp $ + * $Id: stub_store_swapout.cc,v 1.3 2007/04/17 23:05:20 wessels Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Robert Collins @@ -33,22 +33,23 @@ */ #include "squid.h" +#include "Store.h" void -storeSwapOutFileClose(StoreEntry * e) +StoreEntry::swapOutFileClose() { fatal ("Not implemented"); } -int -storeSwapOutAble(const StoreEntry * e) +bool +StoreEntry::swapOutAble() const { fatal ("Not implemented"); - return -1; + return false; } void -storeSwapOut(StoreEntry * e) +StoreEntry::swapOut() { fatal ("Not implemented"); } diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index bb13383bc8..001f6701f9 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -158,7 +158,7 @@ testUfs::testUfsSearch() storeBufferFlush(pe); storeTimestampsSet(pe); pe->complete(); - storeSwapOut(pe); + pe->swapOut(); CPPUNIT_ASSERT(pe->swap_dirn == 0); CPPUNIT_ASSERT(pe->swap_filen == 0); pe->unlock();