From: wessels <> Date: Fri, 13 Apr 2007 00:05:20 +0000 (+0000) Subject: Fixed disk file leak. UFS-based disk files were not always closed X-Git-Tag: SQUID_3_0_PRE6~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdf5b250c38857b5317e424d1de3664d379b2f12;p=thirdparty%2Fsquid.git Fixed disk file leak. UFS-based disk files were not always closed 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. --- diff --git a/src/fs/ufs/store_io_ufs.cc b/src/fs/ufs/store_io_ufs.cc index f0c159d8ad..d2cb7fd2be 100644 --- a/src/fs/ufs/store_io_ufs.cc +++ b/src/fs/ufs/store_io_ufs.cc @@ -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 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; } diff --git a/src/store_io.cc b/src/store_io.cc index 6d3a58774f..2833693056 100644 --- a/src/store_io.cc +++ b/src/store_io.cc @@ -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(); }