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
/*
- * $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
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 */
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);
+}