]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/fs/rock/RockIoState.cc
Fixed StoreMap.cc "anchorAt(anchorId).reading()" assertions (#1117)
[thirdparty/squid.git] / src / fs / rock / RockIoState.cc
index 14749002f20e06efcabfb6ad5b1830148b9cc0ee..c51da8b88bcebf9249ac8e4b8e187dc9c9c93f4b 100644 (file)
@@ -103,6 +103,8 @@ Rock::IoState::read_(char *buf, size_t len, off_t coreOff, STRCB *cb, void *data
     assert(theFile != nullptr);
     assert(coreOff >= 0);
 
+    bool writerLeft = readAnchor().writerHalted; // before the sidCurrent change
+
     // if we are dealing with the first read or
     // if the offset went backwords, start searching from the beginning
     if (sidCurrent < 0 || coreOff < objOffset) {
@@ -112,6 +114,7 @@ Rock::IoState::read_(char *buf, size_t len, off_t coreOff, STRCB *cb, void *data
     }
 
     while (sidCurrent >= 0 && coreOff >= objOffset + currentReadableSlice().size) {
+        writerLeft = readAnchor().writerHalted; // before the sidCurrent change
         objOffset += currentReadableSlice().size;
         sidCurrent = currentReadableSlice().next;
     }
@@ -121,6 +124,13 @@ Rock::IoState::read_(char *buf, size_t len, off_t coreOff, STRCB *cb, void *data
     read.callback = cb;
     read.callback_data = cbdataReference(data);
 
+    // quit if we cannot read what they want, and the writer cannot add more
+    if (sidCurrent < 0 && writerLeft) {
+        debugs(79, 5, "quitting at " << coreOff << " in " << *e);
+        callReaderBack(buf, -1);
+        return;
+    }
+
     // punt if read offset is too big (because of client bugs or collapsing)
     if (sidCurrent < 0) {
         debugs(79, 5, "no " << coreOff << " in " << *e);