]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed disk file leak. UFS-based disk files were not always closed
authorwessels <>
Fri, 13 Apr 2007 00:05:20 +0000 (00:05 +0000)
committerwessels <>
Fri, 13 Apr 2007 00:05:20 +0000 (00:05 +0000)
because the storeClose() may be called when an I/O request is pending.
With this fix, UFSStoreState::writeCompleted now calls tryClosing()
if the try_closing flag is set.

src/fs/ufs/store_io_ufs.cc
src/store_io.cc

index f0c159d8ad1a1a4c390243fd45a80e2c7b26f294..d2cb7fd2be37abe9d21974d26775a43a9d7dae9b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_io_ufs.cc,v 1.34 2006/05/31 17:47:53 wessels Exp $
+ * $Id: store_io_ufs.cc,v 1.35 2007/04/12 18:05:21 wessels Exp $
  *
  * DEBUG: section 79    Storage Manager UFS Interface
  * AUTHOR: Duane Wessels
@@ -345,6 +345,19 @@ UFSStoreState::writeCompleted(int errflag, size_t len, RefCount<WriteRequest> wr
                " detected an error, will try to close");
         tryClosing();
     }
+
+    /*
+     * DPW 2007-04-12
+     * I'm seeing disk files remain open under vanilla UFS storage
+     * because storeClose() gets called before the last write is
+     * complete.  I guess we have to check for the try_closing
+     * flag here.
+     */
+    if (flags.try_closing) {
+       debugs(72, 2, HERE << "UFSStoreState::writeCompleted" <<
+           " flags.try_closing is set");
+       tryClosing();
+    }
 }
 
 void
@@ -494,6 +507,8 @@ UFSStoreState::tryClosing()
            " ioInProgress = " << theFile->ioInProgress());
 
     if (theFile->ioInProgress()) {
+       debugs(79, 3, HERE << this <<
+           " won't close since ioInProgress is true, bailing");
         flags.try_closing = true;
         return;
     }
index 6d3a58774f069863fb6d3ce4a845d952d879d4dd..2833693056ee78ddec71455f21edcfb804e4a1d6 100644 (file)
@@ -81,11 +81,14 @@ storeOpen(StoreEntry * e, StoreIOState::STFNCB * file_callback, StoreIOState::ST
 void
 storeClose(StoreIOState::Pointer sio)
 {
-    if (sio->flags.closing)
+    if (sio->flags.closing) {
+       debugs(20,3,HERE << "storeClose: flags.closing already set, bailing");
         return;
+    }
 
     sio->flags.closing = 1;
 
+    debugs(20,3,HERE << "storeClose: calling sio->close()");
     sio->close();
 }