From: Alex Rousskov Date: Mon, 22 Sep 2008 05:52:37 +0000 (-0600) Subject: Call failed(ERR_FTP_FAILURE, 0) when data channel is closed unexpectidly, X-Git-Tag: SQUID_3_1_0_1~49^2~13^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e92b048e29b6576c1bc0be9bf18140aef5a3f95;p=thirdparty%2Fsquid.git Call failed(ERR_FTP_FAILURE, 0) when data channel is closed unexpectidly, to force control channel closure. Apparently, FtpStateData does not close that channel when cleaning up. Added and polished comments. --- diff --git a/src/ftp.cc b/src/ftp.cc index e81b45d1fb..f23ff07900 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -123,6 +123,7 @@ class FtpStateData; typedef void (FTPSM) (FtpStateData *); /// common code for FTP control and data channels +// does not own the channel descriptor, which is managed by FtpStateData class FtpChannel { public: FtpChannel(): fd(-1) {} @@ -414,7 +415,7 @@ FTPSM *FTP_SM_FUNCS[] = ftpReadMkdir /* SENT_MKDIR */ }; -/// close handler called by Comm when FTP control channel is closed prematurely +/// handler called by Comm when FTP control channel is closed unexpectedly void FtpStateData::ctrlClosed(const CommCloseCbParams &io) { @@ -422,12 +423,13 @@ FtpStateData::ctrlClosed(const CommCloseCbParams &io) deleteThis("FtpStateData::ctrlClosed"); } -/// close handler called by Comm when FTP data channel is closed prematurely +/// handler called by Comm when FTP data channel is closed unexpectedly void FtpStateData::dataClosed(const CommCloseCbParams &io) { data.clear(); - deleteThis("FtpStateData::dataClosed"); + failed(ERR_FTP_FAILURE, 0); // or is it better to call abortTransaction()? + /* failed closes ctrl.fd and frees ftpState */ } FtpStateData::FtpStateData(FwdState *theFwdState) : AsyncJob("FtpStateData"), ServerStateData(theFwdState) @@ -464,6 +466,11 @@ FtpStateData::~FtpStateData() data.close(); + if (ctrl.fd >= 0) { + debugs(9, DBG_IMPORTANT, HERE << "Internal bug: FtpStateData left " << + "control FD " << ctrl.fd << " open"); + } + if (ctrl.buf) { memFreeBuf(ctrl.size, ctrl.buf); ctrl.buf = NULL;