/*
- * $Id: ftp.cc,v 1.403 2006/09/02 10:03:20 adrian Exp $
+ * $Id: ftp.cc,v 1.404 2006/09/10 01:53:00 adrian Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
void printfReplyBody(const char *fmt, ...);
void maybeReadData();
void transactionComplete();
+ void transactionForwardComplete();
+ void transactionAbort();
void processReplyBody();
void writeCommand(const char *buf);
safe_free(filepath);
safe_free(data.host);
+ /* XXX this is also set to NULL in transactionForwardComplete */
fwd = NULL; // refcounted
}
#endif
if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
- transactionComplete();
+ transactionAbort();
return;
}
return;
if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
- ftpState->transactionComplete();
+ ftpState->transactionAbort();
return;
}
return;
}
- ftpState->transactionComplete();
+ /* XXX this may end up having to be transactionComplete() .. */
+ ftpState->transactionAbort();
return;
}
*/
if (!EBIT_TEST(ftpState->entry->flags, ENTRY_ABORTED))
- ftpState->fwd->complete();
+ ftpState->transactionForwardComplete();
ftpSendQuit(ftpState);
return;
if (EBIT_TEST(ftpState->entry->flags, ENTRY_ABORTED)) {
- ftpState->transactionComplete();
+ ftpState->transactionAbort();
return;
}
static void
ftpReadQuit(FtpStateData * ftpState)
{
+ /* XXX should this just be a case of transactionAbort? */
ftpState->transactionComplete();
}
storeAppend(entry, data, len);
}
+/*
+ * We've completed with the forwardstate - finish up if necessary.
+ * This is a simple hack to ensure we don't double-complete on the
+ * forward entry.
+ */
+void
+FtpStateData::transactionForwardComplete()
+{
+ debugs(9,5,HERE << "transactionForwardComplete FD " << ctrl.fd << ", Data FD " << data.fd << ", this " << this);
+ if (fwd == NULL) {
+ fwd->complete();
+ /* XXX this is also set to NULL in the destructor, but we need to do it as early as possible.. -adrian */
+ fwd = NULL; // refcounted
+ }
+
+}
+
+/*
+ * Quickly abort a connection.
+ * This will, for now, just call comm_close(). That'll unravel everything
+ * properly (I hope!) by using abort handlers. This all has to change soon
+ * enough!
+ */
+void
+FtpStateData::transactionAbort()
+{
+ debugs(9,5,HERE << "transactionAbort FD " << ctrl.fd << ", Data FD " << data.fd << ", this " << this);
+ assert(ctrl.fd != -1);
+
+ comm_close(ctrl.fd);
+ /* We could have had our state data freed from underneath us here.. */
+}
+
/*
* Done with the FTP server, so close those sockets. May not be
* done with ICAP yet though. Don't free ftpStateData if ICAP is
void
FtpStateData::transactionComplete()
{
- debugs(9,5,HERE << "transactionComplete FD " << ctrl.fd << " this " << this);
+ debugs(9,5,HERE << "transactionComplete FD " << ctrl.fd << ", Data FD " << data.fd << ", this " << this);
if (ctrl.fd > -1) {
fwd->unregister(ctrl.fd);
#endif
- fwd->complete();
+ transactionForwardComplete();
ftpSocketClosed(-1, this);
}
debug(11,5)("\toops, entry is not Accepting!\n");
icap->ownerAbort();
} else {
- fwd->complete();
+ transactionForwardComplete();
}
/*