From: wessels <> Date: Tue, 21 Apr 1998 05:26:12 +0000 (+0000) Subject: Added storeSwapOutWriteQueued(). X-Git-Tag: SQUID_3_0_PRE1~3485 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61038223a0b3dec82a1a4d328d99b6d2c96f10ea;p=thirdparty%2Fsquid.git Added storeSwapOutWriteQueued(). storeAbort() was improperly checking for no-writes-queued condition by not accounting for the swap meta header size. --- diff --git a/src/protos.h b/src/protos.h index 081921bbda..be3846c6a8 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 diff --git a/src/store.cc b/src/store.cc index 708a278728..eda7e78f73 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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 */ diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 8208a300b6..97b48cecde 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -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); +}