]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Need two offsets in the storeClientCopy stuff. The lower offset is
authorwessels <>
Fri, 23 May 1997 04:53:59 +0000 (04:53 +0000)
committerwessels <>
Fri, 23 May 1997 04:53:59 +0000 (04:53 +0000)
represents the amount of data the client has seen and successfully
dealt with.  The upper offset represents data we have seen, but not dealt
with.  For example, incomplete HTTP reply headers.

src/client_side.cc
src/store.cc

index 987b98d6b40ab1f9b53849b2760436de34a07e70..e63044eb947644c93dc1f0bf2c5a79e182ef51bb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.105 1997/05/22 22:16:52 wessels Exp $
+ * $Id: client_side.cc,v 1.106 1997/05/22 22:53:59 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -341,8 +341,8 @@ icpProcessExpired(int fd, void *data)
        http->request->flags,
        http->request->method);
     /* NOTE, don't call storeLockObject(), storeCreateEntry() does it */
-    storeClientListAdd(entry, http, 0);
-    storeClientListAdd(http->old_entry, http, 0);
+    storeClientListAdd(entry, http);
+    storeClientListAdd(http->old_entry, http);
 
     entry->lastmod = http->old_entry->lastmod;
     debug(33, 5, "icpProcessExpired: setting lmt = %d\n",
@@ -354,6 +354,7 @@ icpProcessExpired(int fd, void *data)
     protoDispatch(fd, http->entry, http->request);
     /* Register with storage manager to receive updates when data comes in. */
     storeClientCopy(entry,
+       http->out.offset,
        http->out.offset,
        4096,
        get_free_4k_page(),
@@ -413,6 +414,7 @@ icpHandleIMSReply(void *data, char *buf, size_t size)
        debug(33, 3, "icpHandleIMSReply: Incomplete headers for '%s'\n",
            entry->url);
        storeClientCopy(entry,
+           http->out.offset + size,
            http->out.offset,
            4096,
            get_free_4k_page(),
@@ -458,6 +460,7 @@ icpHandleIMSReply(void *data, char *buf, size_t size)
     }
     http->old_entry = NULL;    /* done with old_entry */
     storeClientCopy(entry,
+       http->out.offset,
        http->out.offset,
        4096,
        get_free_4k_page(),
index d6aba9a148c562cd5fa2419ded294d2e702ad479..178ad2387a38adc71945639db49dbf8e13cb5b50 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.238 1997/05/22 22:19:49 wessels Exp $
+ * $Id: store.cc,v 1.239 1997/05/22 22:54:01 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -840,31 +840,6 @@ storeAddDiskRestore(const char *url, int file_number, int size, time_t expires,
     return e;
 }
 
-#if OLD_CODE
-/* Register interest in an object currently being retrieved. */
-void
-storeRegister(StoreEntry * e, STCB * callback, void *data, off_t offset)
-{
-    int i;
-    MemObject *mem = e->mem_obj;
-    struct _store_client *sc;
-    debug(20, 3, "storeRegister: '%s'\n", e->key);
-    if ((i = storeClientListSearch(mem, data)) < 0)
-       i = storeClientListAdd(e, data, 0);
-    sc = &mem->clients[i];
-    if (sc->callback)
-       fatal_dump("storeRegister: callback already exists");
-    sc->offset = offset;
-    sc->callback = callback;
-    sc->callback_data = data;
-    if (offset < e->object_len) {
-       sc->callback = NULL;
-       /* Don't NULL the callback_data, its used to identify the client */
-       callback(data);
-    }
-}
-#endif
-
 int
 storeUnregister(StoreEntry * e, void *data)
 {
@@ -877,7 +852,8 @@ storeUnregister(StoreEntry * e, void *data)
     if ((i = storeClientListSearch(mem, data)) < 0)
        return 0;
     sc = &mem->clients[i];
-    sc->offset = 0;
+    sc->seen_offset = 0;
+    sc->copy_offset = 0;
     sc->callback = NULL;
     sc->callback_data = NULL;
     debug(20, 9, "storeUnregister: returning 1\n");
@@ -893,8 +869,8 @@ storeGetLowestReaderOffset(const StoreEntry * entry)
     for (i = 0; i < mem->nclients; i++) {
        if (mem->clients[i].callback_data == NULL)
            continue;
-       if (mem->clients[i].offset < lowest)
-           lowest = mem->clients[i].offset;
+       if (mem->clients[i].copy_offset < lowest)
+           lowest = mem->clients[i].copy_offset;
     }
     return lowest;
 }
@@ -939,7 +915,7 @@ InvokeHandlers(StoreEntry * e)
        sc->callback = NULL;
        /* Don't NULL the callback_data, its used to identify the client */
        size = memCopy(mem->data,
-           sc->offset,
+           sc->copy_offset,
            sc->copy_buf,
            sc->copy_size);
        callback(sc->callback_data, sc->copy_buf, size);
@@ -2193,7 +2169,7 @@ storeClientListSearch(const MemObject * mem, void *data)
 
 /* add client with fd to client list */
 int
-storeClientListAdd(StoreEntry * e, void *data, int offset)
+storeClientListAdd(StoreEntry * e, void *data)
 {
     int i;
     MemObject *mem = e->mem_obj;
@@ -2222,7 +2198,8 @@ storeClientListAdd(StoreEntry * e, void *data, int offset)
        i = oldsize;
     }
     mem->clients[i].callback_data = data;
-    mem->clients[i].offset = offset;
+    mem->clients[i].seen_offset = 0;
+    mem->clients[i].copy_offset = 0;
     return i;
 }
 
@@ -2230,7 +2207,8 @@ storeClientListAdd(StoreEntry * e, void *data, int offset)
  * for each client */
 void
 storeClientCopy(StoreEntry * e,
-    off_t offset,
+    off_t seen_offset,
+    off_t copy_offset,
     size_t size,
     char *buf,
     STCB * callback,
@@ -2239,23 +2217,23 @@ storeClientCopy(StoreEntry * e,
     int ci;
     size_t sz;
     MemObject *mem = e->mem_obj;
-    if (offset < mem->e_lowest_offset) {
-       debug_trap("storeClientCopy: requested offset < lowest offset");
-       debug(20, 0, " --> %d < %d\n",
-           offset, mem->e_lowest_offset);
-       debug(20, 0, "--> '%s'\n", e->url);
-       return;
-    }
+    struct _store_client *sc;
+    assert(seen_offset <= mem->e_current_len);
+    assert(copy_offset < mem->e_lowest_offset);
     if ((ci = storeClientListSearch(mem, data)) < 0)
        fatal_dump("storeClientCopy: Unregistered client");
-    mem->clients[ci].offset = offset;
-    if (offset >= mem->e_current_len) {
-       mem->clients[ci].callback = callback;
-       mem->clients[ci].copy_buf = buf;
-       mem->clients[ci].copy_size = size;
+    sc = &mem->clients[ci];
+    sc->copy_offset = copy_offset;
+    sc->seen_offset = seen_offset;
+    if (seen_offset == mem->e_current_len) {
+       /* client has already seen this, wait for more */
+       sc->callback = callback;
+       sc->copy_buf = buf;
+       sc->copy_size = size;
+       sc->copy_offset = copy_offset;
        return;
     }
-    sz = memCopy(mem->data, offset, buf, size);
+    sz = memCopy(mem->data, copy_offset, buf, size);
     callback(data, buf, sz);
     /* see if we can get rid of some data if we are in "delete behind" mode . */
     if (BIT_TEST(e->flag, DELETE_BEHIND))