]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
file_close should call the read_handler if set so we can free
authorwessels <>
Thu, 20 Aug 1998 22:04:07 +0000 (22:04 +0000)
committerwessels <>
Thu, 20 Aug 1998 22:04:07 +0000 (22:04 +0000)
dread_ctrl state

src/disk.cc

index 4cfdb7554a1f59d7daa3bb3edff5c362b59fca6e..00b579eaa626f97d0f1668e9a5bb49a74fdc05cd 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: disk.cc,v 1.128 1998/08/18 22:42:18 wessels Exp $
+ * $Id: disk.cc,v 1.129 1998/08/20 16:04:07 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -127,6 +127,7 @@ void
 file_close(int fd)
 {
     fde *F = &fd_table[fd];
+    PF *callback;
 #if USE_ASYNC_IO
     if (fd < 0) {
        debug(6, 0) ("file_close: FD less than zero: %d\n", fd);
@@ -136,11 +137,20 @@ file_close(int fd)
     assert(fd >= 0);
 #endif
     assert(F->open);
+    if ((callback = F->read_handler)) {
+       F->read_handler = NULL;
+       callback(-1, F->read_data);
+    }
     if (F->flags.write_daemon) {
        F->flags.close_request = 1;
        debug(6, 2) ("file_close: FD %d, delaying close\n", fd);
        return;
     }
+    /*
+     * Assert there is no write callback.  Otherwise we might be
+     * leaking write state data by closing the descriptor
+     */
+    assert(F->write_handler == NULL);
 #if USE_ASYNC_IO
     aioClose(fd);
 #else
@@ -427,6 +437,14 @@ diskHandleRead(int fd, void *data)
 #ifdef OPTIMISTIC_IO
     assert(!F->flags.calling_io_handler);
 #endif /* OPTIMISTIC_IO */
+    /*
+     * FD < 0 indicates premature close; we just have to free
+     * the state data.
+     */
+    if (fd < 0) {
+        memFree(MEM_DREAD_CTRL, ctrl_dat);
+       return;
+    }
 #if USE_ASYNC_IO
     aioRead(fd,
        ctrl_dat->offset,