]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Summary: Merge of projects@swelltech.com--private/squid--mem-to-disk--3.0--patch-1
authorrobertc <>
Fri, 11 Jul 2003 10:02:01 +0000 (10:02 +0000)
committerrobertc <>
Fri, 11 Jul 2003 10:02:01 +0000 (10:02 +0000)
Keywords:
MergeOf: projects@swelltech.com--private/squid--mem-to-disk--3.0--patch-1

Patches applied:

  * projects@swelltech.com--private/squid--mem-to-disk--3.0--patch-1
     Refactoring store_client.

  * projects@swelltech.com--private/squid--mem-to-disk--3.0--base-0
     tag of projects@swelltech.com--private/squid--ign--3.0--patch-76

* extract disk read scheduling from store_client::doCopy.
* Ditto for mem scheduling.
* Extract choice of memory or disk reads from store_client::doCopy.
* Extract logic surrounding disk opens from store_client::doCopy.

src/StoreClient.h
src/store_client.cc
src/store_swapout.cc

index c63cf981300cb88a6425787d116e568f27c6d034..4c9636acf39fe040eed2a27f6ec5728413bdf169 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: StoreClient.h,v 1.9 2003/02/21 22:50:06 robertc Exp $
+ * $Id: StoreClient.h,v 1.10 2003/07/11 04:02:01 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -110,6 +110,10 @@ private:
     static MemPool *pool;
 
     void fileRead();
+    void scheduleDiskRead();
+    void scheduleMemRead();
+    void scheduleRead();
+    void startSwapin();
     void unpackHeader(char const *buf, ssize_t len);
 
     int type;
index bef8d15223b3b6b30eaf81c597150e44f54ea45d..0120e156962948748453f12e30377fc61a0dd525 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_client.cc,v 1.129 2003/07/11 01:40:37 robertc Exp $
+ * $Id: store_client.cc,v 1.130 2003/07/11 04:02:01 robertc Exp $
  *
  * DEBUG: section 90    Storage Manager Client-Side Interface
  * AUTHOR: Duane Wessels
@@ -368,47 +368,61 @@ store_client::doCopy(StoreEntry *anEntry)
      * if needed.
      */
 
-    if (STORE_DISK_CLIENT == getType() && NULL == swapin_sio.getRaw()) {
-        debug(90, 3)("store_client::doCopy: Need to open swap in file\n");
-        /* gotta open the swapin file */
+    if (STORE_DISK_CLIENT == getType() && NULL == swapin_sio.getRaw())
+        startSwapin();
+    else
+        scheduleRead();
+}
 
-        if (storeTooManyDiskFilesOpen()) {
-            /* yuck -- this causes a TCP_SWAPFAIL_MISS on the client side */
-            fail();
-            flags.store_copying = 0;
-            return;
-        } else if (!flags.disk_io_pending) {
-            /* Don't set store_io_pending here */
-            storeSwapInStart(this);
-
-            if (NULL == swapin_sio.getRaw()) {
-                fail();
-                flags.store_copying = 0;
-                return;
-            }
+void
+store_client::startSwapin()
+{
+    debug(90, 3)("store_client::doCopy: Need to open swap in file\n");
+    /* gotta open the swapin file */
+
+    if (storeTooManyDiskFilesOpen()) {
+        /* yuck -- this causes a TCP_SWAPFAIL_MISS on the client side */
+        fail();
+        flags.store_copying = 0;
+        return;
+    } else if (!flags.disk_io_pending) {
+        /* Don't set store_io_pending here */
+        storeSwapInStart(this);
 
-            /*
-             * If the open succeeds we either copy from memory, or
-             * schedule a disk read in the next block.
-             */
-        } else {
-            debug (90, 1)("WARNING: Averted multiple fd operation (1)\n");
+        if (NULL == swapin_sio.getRaw()) {
+            fail();
             flags.store_copying = 0;
             return;
         }
-    }
 
-    if (copyInto.offset >= mem->inmem_lo && copyInto.offset < mem->endOffset()) {
-        /* What the client wants is in memory */
-        /* Old style */
-        debug(90, 3)("store_client::doCopy: Copying normal from memory\n");
-        size_t sz = mem->data_hdr.copy(copyInto.offset, copyInto.data,
-                                       copyInto.length);
-        callback(sz);
+        /*
+         * If the open succeeds we either copy from memory, or
+         * schedule a disk read in the next block.
+         */
+        scheduleRead();
+
+        return;
+    } else {
+        debug (90, 1)("WARNING: Averted multiple fd operation (1)\n");
         flags.store_copying = 0;
         return;
     }
+}
+
+void
+store_client::scheduleRead()
+{
+    MemObject *mem = entry->mem_obj;
+
+    if (copyInto.offset >= mem->inmem_lo && copyInto.offset < mem->endOffset())
+        scheduleMemRead();
+    else
+        scheduleDiskRead();
+}
 
+void
+store_client::scheduleDiskRead()
+{
     /* What the client wants is not in memory. Schedule a disk read */
     assert(STORE_DISK_CLIENT == getType());
 
@@ -421,6 +435,19 @@ store_client::doCopy(StoreEntry *anEntry)
     flags.store_copying = 0;
 }
 
+void
+store_client::scheduleMemRead()
+{
+    /* What the client wants is in memory */
+    /* Old style */
+    debug(90, 3)("store_client::doCopy: Copying normal from memory\n");
+    MemObject *mem = entry->mem_obj;
+    size_t sz = mem->data_hdr.copy(copyInto.offset, copyInto.data,
+                                   copyInto.length);
+    callback(sz);
+    flags.store_copying = 0;
+}
+
 void
 store_client::fileRead()
 {
index 943901a20f51d76a14e249f982178bf4b4747d98..0b6626783d78292d2120459e4753b4f16153539c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_swapout.cc,v 1.95 2003/06/26 12:51:58 robertc Exp $
+ * $Id: store_swapout.cc,v 1.96 2003/07/11 04:02:01 robertc Exp $
  *
  * DEBUG: section 20    Storage Manager Swapout Functions
  * AUTHOR: Duane Wessels
@@ -377,6 +377,8 @@ storeSwapOutAble(const StoreEntry * e)
      * even if its not cachable
      * RBC: Surely we should not create disk client on non cacheable objects?
      * therefore this should be an assert?
+     * 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) {
         if (((store_client *) node->data)->getType() == STORE_DISK_CLIENT)