]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Converted three store_swapout.cc functions to StoreEntry class methods
authorwessels <>
Wed, 18 Apr 2007 05:05:17 +0000 (05:05 +0000)
committerwessels <>
Wed, 18 Apr 2007 05:05:17 +0000 (05:05 +0000)
storeSwapOut() is now StoreEntry::swapOut()
storeSwapOutFileClose() is now StoreEntry::swapOutFileClose()
storeSwapOutAble() is now Storeentry::swapOutAble()

src/Store.h
src/protos.h
src/store.cc
src/store_client.cc
src/store_swapout.cc
src/tests/stub_store_swapout.cc
src/tests/testUfs.cc

index adef41942607a99ca8217f2a4b8b430ff504ca9d..ddf30d49ebe54bc87b9c7d8541721c5a0022d10f 100644 (file)
@@ -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);
 
index fc9785d6d94b4fb997198e0e0a1468dc6ee3baf7..c692949ae35822d8aab10660c38e939e9e50ef54 100644 (file)
@@ -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
  */
index 4198ae92ed59136d6f9aebc94c6093ec226c8f8b..1636fac7501abf48c0119f15e90bc9146d8b2e6e 100644 (file)
@@ -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
index 9c2172f4582b6826039c11880c8be1c2a7445cf1..5c914c9e765461b38656330a3bb37de16f46fd6e 100644 (file)
@@ -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;
index 55e89912fa415ab763a9d65113b91269887af6fb..2774313010c03f8b4e9888b4d381c57730aa8d48 100644 (file)
@@ -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;
 }
index f59d10fa13c05d04e358187a185da20a86a65e8b..549ba9f1494f24f2de9819168235d15ee0c98a80 100644 (file)
@@ -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
  */
 
 #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");
 }
index bb13383bc867c382a5bd28acde66814852d50ec5..001f6701f9e5ef7eae4f9748b7356aba4bcc3b55 100644 (file)
@@ -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();