patch to head and 2.4 for diskd

From: Adrian Chadd <adrian@dont-contact.us>
Date: Sat, 25 Nov 2000 02:58:11 +0800

Here is a patch against HEAD. If you assert() on the close_request with
this patch inside storeDiskdReadDone() to die if close_request is 1,
I can reliably triugger it by ctrl-C'ing a polyclt during a polygraph
run.

Can someone check my logic here? We only have a single op on an FS
(read or write) scheduled one one sio at a time, so we can implement
a cancel based on close_request ..

Adrian

----- Forwarded message from Adrian Chadd <adrian@nympho.cacheboy.net> -----

Date: Fri, 24 Nov 2000 19:43:16 +0100 (CET)
From: Adrian Chadd <adrian@nympho.cacheboy.net>
To: adrian@creative.net.au

Index: store_io_diskd.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/diskd/store_io_diskd.c,v
retrieving revision 1.16
diff -u -r1.16 store_io_diskd.c
--- store_io_diskd.c 2000/10/06 05:00:24 1.16
+++ store_io_diskd.c 2000/11/24 18:35:33
@@ -184,6 +184,7 @@
         debug(50, 1) ("storeDiskdSend CLOSE: %s\n", xstrerror());
         storeDiskdIOCallback(sio, DISK_ERROR);
     }
+ diskdstate->flags.close_request = 1;
     diskd_stats.close.ops++;
 }
 
@@ -194,6 +195,8 @@
     int shm_offset;
     char *rbuf;
     diskdstate_t *diskdstate = sio->fsstate;
+ debug(81, 3) ("storeDiskdRead: dirno %d, fileno %08X\n", sio->swap_dirn, sio->swap_filen);
+ assert(!diskdstate->flags.close_request);
     if (!cbdataValid(sio))
         return;
     if (diskdstate->flags.reading) {
@@ -206,7 +209,6 @@
     sio->read.callback_data = callback_data;
     diskdstate->read_buf = buf; /* the one passed from above */
     cbdataLock(sio->read.callback_data);
- debug(81, 3) ("storeDiskdRead: dirno %d, fileno %08X\n", sio->swap_dirn, sio->swap_filen);
     sio->offset = offset;
     diskdstate->flags.reading = 1;
     rbuf = storeDiskdShmGet(SD, &shm_offset);
@@ -234,6 +236,7 @@
     int shm_offset;
     diskdstate_t *diskdstate = sio->fsstate;
     debug(81, 3) ("storeDiskdWrite: dirno %d, fileno %08X\n", SD->index, sio->swap_filen);
+ assert(!diskdstate->flags.close_request);
     if (!cbdataValid(sio)) {
         free_func(buf);
         return;
@@ -355,14 +358,22 @@
     diskd_stats.read.success++;
     sbuf = diskdinfo->shm.buf + M->shm_offset;
     len = M->status;
- xmemcpy(their_buf, sbuf, len); /* yucky copy */
     sio->offset += len;
     assert(callback);
     assert(their_data);
     sio->read.callback = NULL;
     sio->read.callback_data = NULL;
- if (valid)
+ if (valid) {
+ assert(!diskdstate->flags.close_request);
+ /*
+ * Only copy the data if the callback is still valid,
+ * if it isn't valid then the request should have been
+ * aborted.
+ * -- adrian
+ */
+ xmemcpy(their_buf, sbuf, len); /* yucky copy */
         callback(their_data, their_buf, len);
+ }
 }
 
 static void

----- End forwarded message -----

-- 
Adrian Chadd			"God: Damn! I left pot everywhere!
<adrian@creative.net.au>	  Now I'll have to create Republicans!"
				    - Bill Hicks
Received on Fri Nov 24 2000 - 11:58:28 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:00 MST