/*
- * $Id: ftp.cc,v 1.386 2006/02/20 12:45:34 serassio Exp $
+ * $Id: ftp.cc,v 1.387 2006/02/21 22:42:24 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
#endif
if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
- comm_close(ctrl.fd);
+ transactionComplete();
return;
}
entry->replaceHttpReply(reply);
- fwd->complete();
-
- comm_close(ctrl.fd);
+ transactionComplete();
return;
}
return;
if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
- comm_close(ftpState->ctrl.fd);
+ ftpState->transactionComplete();
return;
}
return;
}
- comm_close(ftpState->ctrl.fd);
+ ftpState->transactionComplete();
return;
}
if (ftpState->data.fd >= 0) {
/* Close old connection */
- comm_close(ftpState->data.fd);
- ftpState->data.fd = -1;
+ ftpState->transactionComplete();
}
if (!ftpState->flags.pasv_supported) {
return;
if (EBIT_TEST(ftpState->entry->flags, ENTRY_ABORTED)) {
- comm_close(ftpState->ctrl.fd);
+ ftpState->transactionComplete();
return;
}
if (ftpState->flags.html_header_sent)
ftpState->listingFinish();
- ftpState->transactionComplete();
+ ftpSendQuit(ftpState);
} else { /* != 226 */
debug(9, 1) ("ftpReadTransferDone: Got code %d after reading data\n",
code);
static void
ftpReadQuit(FtpStateData * ftpState)
{
- comm_close(ftpState->ctrl.fd);
+ ftpState->transactionComplete();
}
static void
if (entry->isEmpty())
failedErrorMessage(error, xerrno);
- if (data.fd > -1) {
- comm_close(data.fd);
- data.fd = -1;
- }
-
- comm_close(ctrl.fd);
+ transactionComplete();
}
void
storeAppend(entry, data, len);
}
-
+/*
+ * Done with the FTP server, so close those sockets. May not be
+ * done with ICAP yet though. Don't free ftpStateData if ICAP is
+ * still around.
+ */
void
FtpStateData::transactionComplete()
{
debugs(9,5,HERE << "transactionComplete FD " << ctrl.fd << " this " << this);
- fwd->unregister(ctrl.fd);
+ if (ctrl.fd > -1) {
+ fwd->unregister(ctrl.fd);
+ comm_remove_close_handler(ctrl.fd, ftpSocketClosed, this);
+ comm_close(ctrl.fd);
+ ctrl.fd = -1;
+ }
- ftpSendQuit(this);
+ if (data.fd > -1) {
+ comm_close(data.fd);
+ data.fd = -1;
+ }
#if ICAP_CLIENT
#endif
fwd->complete();
+
+ ftpSocketClosed(-1, this);
}
#if ICAP_CLIENT