]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not allow broken IpcIo-based cache_dir to be selected for swap out.
authorAlex Rousskov <rousskov@measurement-factory.com>
Sun, 20 Jan 2013 17:31:50 +0000 (10:31 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Sun, 20 Jan 2013 17:31:50 +0000 (10:31 -0700)
I/O code refuses to read or write when file error is set, but canRead()
and canWrite() ignored that fact, allowing broken files to be selected for
writing (at least). SwapDir::createStoreIO() would then return nil, leading
to missed swapout opportunities (if other cache_dirs could write) and wasted
CPU cycles.

src/DiskIO/IpcIo/IpcIoFile.cc

index 83d8f13f86cfb4c8223a94d792986dbd6acc626b..52ea41136dcc3be68fc43fef6799385bbdcf33e3 100644 (file)
@@ -184,13 +184,13 @@ IpcIoFile::close()
 bool
 IpcIoFile::canRead() const
 {
-    return diskId >= 0 && canWait();
+    return diskId >= 0 && !error_ && canWait();
 }
 
 bool
 IpcIoFile::canWrite() const
 {
-    return diskId >= 0 && canWait();
+    return diskId >= 0 && !error_ && canWait();
 }
 
 bool