HttpStateData::processReply() calls adaptOrFinalizeReply(), which
calls ServerStateData::setFinalReply(), which calls
entry->startWriting(), which calls StoreEntry::invokeHandlers() which
calls client-side code, which may abort or otherwise "close" the
entry.
After adaptOrFinalizeReply() returns to HttpStateData::processReply(),
HttpStateData::processReply() calls HttpStateData::processReplyBody(),
which may try to write to the aborted/closed entry, leading to
asserts.
At least the following scenario triggers the bug:
* client send a regular GET for a cached stale object
* Squid sends an IMS verification request to the origin server
* the origin server replies with 304 (Not Modified)
In this case adaptOrFinalizeReply() in HttpStateData::processReply()
would abort the origin server reply entry, leading to assert.
The patch adds a checks that entry still can accept more data after
the adaptOrFinalizeReply() call.
return; // TODO: send errors to ICAP
adaptOrFinalizeReply();
+ // adaptOrFinalizeReply() may abort or otherwise "close" the entry
+ if (!entry->isAccepting())
+ return;
}
// kick more reads if needed and/or process the response body, if any