]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added storeSwapOutWriteQueued().
authorwessels <>
Tue, 21 Apr 1998 05:26:12 +0000 (05:26 +0000)
committerwessels <>
Tue, 21 Apr 1998 05:26:12 +0000 (05:26 +0000)
storeAbort() was improperly checking for no-writes-queued condition
by not accounting for the swap meta header size.

src/protos.h
src/store.cc
src/store_swapout.cc

index 081921bbda4854dff5a93ddb4b6179d018991fc7..be3846c6a8afb911d3086c6e400805532595e3c1 100644 (file)
@@ -772,6 +772,7 @@ extern void storeSwapOutStart(StoreEntry * e);
 extern void storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data);
 extern void storeCheckSwapOut(StoreEntry * e);
 extern void storeSwapOutFileClose(StoreEntry * e);
+int storeSwapOutWriteQueued(MemObject *mem);
 
 /*
  * store_client.c
index 708a27872802e4e64f03e597205cad0ffeb427f2..eda7e78f73c66950e37eab71ba3227e53dea360f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.405 1998/04/17 04:24:25 wessels Exp $
+ * $Id: store.cc,v 1.406 1998/04/20 23:26:17 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager
  * AUTHOR: Harvest Derived
@@ -593,7 +593,7 @@ storeAbort(StoreEntry * e, int cbflag)
            aioCancel(mem->swapout.fd, NULL);
 #endif
        /* we have to close the disk file if there is no write pending */
-       if (mem->swapout.queue_offset == mem->swapout.done_offset)
+       if (!storeSwapOutWriteQueued(mem))
            storeSwapOutFileClose(e);
     }
     storeUnlockObject(e);      /* unlock */
index 8208a300b6c60bc3c61171dbe89847971a334403..97b48cecdeada339ca86290176d038f730f182c7 100644 (file)
@@ -260,3 +260,25 @@ storeSwapOutFileOpened(void *data, int fd, int errcode)
        ctrlp,
        xfree);
 }
+
+/*
+ * Return 1 if we have some data queued.  If there is no data queued,
+ * then 'done_offset' equals 'queued_offset' + 'swap_hdr_sz'
+ *
+ * done_offset represents data written to disk (including the swap meta
+ * header), but queued_offset is relative to the in-memory data, and
+ * does not include the meta header.
+ */
+int
+storeSwapOutWriteQueued(MemObject *mem)
+{
+    /*
+     * this function doesn't get called much, so I'm using
+     * local variables to improve readability.  pphhbbht.
+     */
+    off_t queued = mem->swapout.queue_offset;
+    off_t done = mem->swapout.done_offset;
+    size_t hdr = mem->swap_hdr_sz;
+    assert(queued + hdr >= done);
+    return (queued + hdr == done);
+}