From: hno <> Date: Sun, 7 Sep 2003 22:53:37 +0000 (+0000) Subject: Bug #769: assertion failed: ftp.cc:1150: "fd == ftpState->data.fd" X-Git-Tag: SQUID_3_0_PRE4~1215 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c7568c7e89bd0709ef9f50b7a76ce1dc0544099;p=thirdparty%2Fsquid.git Bug #769: assertion failed: ftp.cc:1150: "fd == ftpState->data.fd" Did not deal with COMM_ERR_CLOSING correctly on aborted requests. --- diff --git a/src/ftp.cc b/src/ftp.cc index 988630cf21..a15fbe72a7 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.354 2003/09/01 03:49:38 robertc Exp $ + * $Id: ftp.cc,v 1.355 2003/09/07 16:53:37 hno Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1135,44 +1135,47 @@ ftpDataComplete(FtpStateData * ftpState) } static void -ftpDataRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +ftpDataRead(int fd, char *buf, size_t len, comm_err_t errflag, int xerrno, void *data) { FtpStateData *ftpState = (FtpStateData *)data; int j; int bin; StoreEntry *entry = ftpState->entry; size_t read_sz; -#if DELAY_POOLS - DelayId delayId = entry->mem_obj->mostBytesAllowed(); -#endif + debug(9, 5) ("ftpDataRead: FD %d, Read %d bytes\n", fd, (unsigned int)len); - assert(fd == ftpState->data.fd); - /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us - */ + if (len > 0) { + kb_incr(&statCounter.server.all.kbytes_in, len); + kb_incr(&statCounter.server.ftp.kbytes_in, len); + } - if (flag == COMM_ERR_CLOSING) { + if (errflag == COMM_ERR_CLOSING) return; - } + + assert(fd == ftpState->data.fd); + +#if DELAY_POOLS + + DelayId delayId = entry->mem_obj->mostBytesAllowed(); + +#endif if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { comm_close(ftpState->ctrl.fd); return; } - if (flag == COMM_OK && len > 0) { + if (errflag == COMM_OK && len > 0) { #if DELAY_POOLS delayId.bytesIn(len); #endif - kb_incr(&statCounter.server.all.kbytes_in, len); - kb_incr(&statCounter.server.ftp.kbytes_in, len); ftpState->data.offset += len; } - debug(9, 5) ("ftpDataRead: FD %d, Read %d bytes\n", fd, (unsigned int)len); - if (flag == COMM_OK && len > 0) { + if (errflag == COMM_OK && len > 0) { IOStats.Ftp.reads++; for (j = len - 1, bin = 0; j; bin++) @@ -1185,7 +1188,7 @@ ftpDataRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *da ftpListingStart(ftpState); } - if (flag != COMM_OK || len < 0) { + if (errflag != COMM_OK || len < 0) { debug(50, ignoreErrno(xerrno) ? 3 : 1) ("ftpDataRead: read error: %s\n", xstrerr(xerrno)); if (ignoreErrno(xerrno)) { @@ -1578,18 +1581,19 @@ ftpScheduleReadControlReply(FtpStateData * ftpState, int buffered_ok) } static void -ftpReadControlReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +ftpReadControlReply(int fd, char *buf, size_t len, comm_err_t errflag, int xerrno, void *data) { FtpStateData *ftpState = (FtpStateData *)data; StoreEntry *entry = ftpState->entry; - debug(9, 5) ("ftpReadControlReply\n"); + debug(9, 5) ("ftpReadControlReply: FD %d, Read %d bytes\n", fd, (int)len); - /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us - */ + if (len > 0) { + kb_incr(&statCounter.server.all.kbytes_in, len); + kb_incr(&statCounter.server.ftp.kbytes_in, len); + } - if (flag == COMM_ERR_CLOSING) { + if (errflag == COMM_ERR_CLOSING) return; - } if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { comm_close(ftpState->ctrl.fd); @@ -1598,15 +1602,12 @@ ftpReadControlReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, assert(ftpState->ctrl.offset < (off_t)ftpState->ctrl.size); - if (flag == COMM_OK && len > 0) { + if (errflag == COMM_OK && len > 0) { fd_bytes(fd, len, FD_READ); - kb_incr(&statCounter.server.all.kbytes_in, len); - kb_incr(&statCounter.server.ftp.kbytes_in, len); } - debug(9, 5) ("ftpReadControlReply: FD %d, Read %d bytes\n", fd, (int)len); - if (flag != COMM_OK || len < 0) { + if (errflag != COMM_OK || len < 0) { debug(50, ignoreErrno(xerrno) ? 3 : 1) ("ftpReadControlReply: read error: %s\n", xstrerr(xerrno)); if (ignoreErrno(xerrno)) { @@ -2364,9 +2365,8 @@ ftpAcceptDataConnection(int fd, int newfd, ConnectionDetail *details, FtpStateData *ftpState = (FtpStateData *)data; debug(9, 3) ("ftpAcceptDataConnection\n"); - if (flag == COMM_ERR_CLOSING) { + if (flag == COMM_ERR_CLOSING) return; - } if (EBIT_TEST(ftpState->entry->flags, ENTRY_ABORTED)) { comm_close(ftpState->ctrl.fd);