[squid-dev] [PATCH] assertion failed: Write.cc:41: "!ccb->active()"

Christos Tsantilas christos at chtsanti.net
Thu Mar 10 19:14:11 UTC 2016


Hi all,
  I am attaching two patches for this bug. One simple for squid-3.5 (t1 
patch) and one more complex (t2 patch). The simple patch solve the bug 
for now, but may leave other similar bugs in squid.

Bug description:
    - The client side and server side are finished
    - On server side the Ftp::Relay::finalizeDataDownload() is called and
      schedules the Ftp::Server::originDataCompletionCheckpoint
    - On client side the "Ftp::Server::userDataCompletionCheckpoint" is
      called. This is schedules a write to control connection and closes
      data connection.
    - The Ftp::Server::originDataCompletionCheckpoint is called which is
      trying to write to control connection and the assertion triggered.

This bug is an corner case, where the client-side  (FTP::Server) should 
wait for the server side (Ftp::Client/Ftp::Relay) to finish its job 
before respond to the FTP client. In this bug the existing mechanism, 
designed to handle such problems, did not worked correctly and resulted 
to a double writing to the client.

To understand why it is important such mechanism, imagine the case where 
an FTP client download a huge file and the ICAP server
block this file. In this case Squid needs to delay response to the FTP
client until the squid server-side closes its data connection too and
get the response from FTP server. This is required because we can not 
accept more commands from FTP client, if we can not forward them to the 
FTP server.

Moreover Squid can fall into such cases when a download or upload may 
aborted abnormally by one of the client or server.  The problem can 
become more complicated if ICAP/adaptation is used and squid respond to 
a download request without contacting the FTP server.

This patch try to fix the existing mechanism as follows:
- When Ftp::Server receives a "startWaitingForOrigin" callback, 
postpones writting possible responses to the client and keeps waiting 
for the stopWaitingForOrigin callback

- When the Ftp::Server receives a "stopWaitingForOrigin" callback, 
resumes any postponed response.

- When the Ftp::Client starts working on a DATA-related transaction 
calls the Ftp::Server::startWaitingForOrigin callback

- When the Ftp::Client finishes its job or when its abort abnormaly, 
checks whether it needs to call Ftp::Server::stopWaitingForOrigin callback.

- Also this patch try to fix the status code returned to the FTP client 
taking in account the status code returned by FTP server. The 
"Ftp::Server::stopWaitingForOrigin" is used to pass the returned status 
code to the client side.

This is a Measurement Factory project


-------------- next part --------------
A non-text attachment was scrubbed...
Name: SQUID-156-assertion_failed_Write.cc_41-not_ccb_active-squid-3.5-t1.patch
Type: text/x-patch
Size: 5069 bytes
Desc: not available
URL: <http://lists.squid-cache.org/pipermail/squid-dev/attachments/20160310/d9f24d41/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SQUID-156-assertion_failed_Write.cc_41-not_ccb_active-trunk-t2.patch
Type: text/x-patch
Size: 26352 bytes
Desc: not available
URL: <http://lists.squid-cache.org/pipermail/squid-dev/attachments/20160310/d9f24d41/attachment-0003.bin>


More information about the squid-dev mailing list