]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
more sophsticated determination of store client type
authorwessels <>
Sun, 20 Sep 1998 02:51:20 +0000 (02:51 +0000)
committerwessels <>
Sun, 20 Sep 1998 02:51:20 +0000 (02:51 +0000)
src/enums.h
src/store_client.cc

index a82604c1d6253e56dbff1e373e27465bb4e61658..69629f12986f420debec84fec14837265c020d2f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.130 1998/09/19 17:06:00 wessels Exp $
+ * $Id: enums.h,v 1.131 1998/09/19 20:51:21 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -349,11 +349,11 @@ enum {
     SWAPOUT_DONE
 };
 
-enum {
+typedef enum {
     STORE_NON_CLIENT,
     STORE_MEM_CLIENT,
     STORE_DISK_CLIENT
-};
+} store_client_t;
 
 enum {
     METHOD_NONE,               /* 000 */
index c0c89a70d9d20f82a8cf4e7605de2f5d68b89681..1deea9f979530410e9cb943213fe60220b5004cc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_client.cc,v 1.43 1998/09/19 17:06:13 wessels Exp $
+ * $Id: store_client.cc,v 1.44 1998/09/19 20:51:20 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager Client-Side Interface
  * AUTHOR: Duane Wessels
@@ -46,6 +46,7 @@ static SIH storeClientFileOpened;
 static void storeClientCopy2(StoreEntry * e, store_client * sc);
 static void storeClientFileRead(store_client * sc);
 static EVH storeClientCopyEvent;
+static store_client_t storeClientType(StoreEntry *);
 
 /* check if there is any client waiting for this object at all */
 /* return 1 if there is at least one client */
@@ -72,6 +73,34 @@ storeClientListSearch(const MemObject * mem, void *data)
     return sc;
 }
 
+static store_client_t
+storeClientType(StoreEntry *e)
+{
+    MemObject *mem = e->mem_obj;
+    /*
+     * If some data has been freed from memory, then we must swap in
+     */
+    if (mem->inmem_lo)
+       return STORE_DISK_CLIENT;
+    /*
+     * If we're not transferring, we have the whole thing and there
+     * will be no delays delivering this to the client
+     */
+    else if (e->store_status != STORE_PENDING)
+       return STORE_MEM_CLIENT;
+    /*
+     * If this is the first client, let it be the mem client
+     */
+    else if (mem->nclients > 1)
+       return STORE_DISK_CLIENT;
+    /*
+     * otherwise, make subsequent clients read from disk so they
+     * can not delay the first, and vice-versa.
+     */
+    else
+       return STORE_MEM_CLIENT;
+}
+
 /* add client with fd to client list */
 void
 storeClientListAdd(StoreEntry * e, void *data)
@@ -91,16 +120,11 @@ storeClientListAdd(StoreEntry * e, void *data)
     sc->swapin_fd = -1;
     sc->flags.disk_io_pending = 0;
     sc->entry = e;
-    if (e->store_status == STORE_PENDING && mem->swapout.fd == -1) {
-       sc->type = STORE_MEM_CLIENT;
-       /* assert we'll be able to get the data we want */
-       assert(mem->inmem_lo == 0);
-    } else {
-       sc->type = STORE_DISK_CLIENT;
+    sc->type = storeClientType(e);
+    if (sc->type == STORE_DISK_CLIENT)
        /* assert we'll be able to get the data we want */
        /* maybe we should open swapin_fd here */
        assert(e->swap_file_number > -1);
-    }
     for (T = &mem->clients; *T; T = &(*T)->next);
     *T = sc;
 }