--------------------- PatchSet 7091 Date: 2005/10/10 14:09:28 Author: adri Branch: tidyup_deferred_reads Tag: (none) Log: Start breaking out the data IO path into our little hinting framework. Control connection dataflow isn't limited/touched by this. This passed simple verification of fetching FTP stuff. Members: src/ftp.c:1.18.6.20.4.1->1.18.6.20.4.2 Index: squid/src/ftp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v retrieving revision 1.18.6.20.4.1 retrieving revision 1.18.6.20.4.2 diff -u -r1.18.6.20.4.1 -r1.18.6.20.4.2 --- squid/src/ftp.c 27 Sep 2005 04:57:14 -0000 1.18.6.20.4.1 +++ squid/src/ftp.c 10 Oct 2005 14:09:28 -0000 1.18.6.20.4.2 @@ -1,6 +1,6 @@ /* - * $Id: ftp.c,v 1.18.6.20.4.1 2005/09/27 04:57:14 adri Exp $ + * $Id: ftp.c,v 1.18.6.20.4.2 2005/10/10 14:09:28 adri Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -915,6 +915,19 @@ } static void +ftpScheduleDataRead(FtpStateData *ftpState) +{ + debug(9, 3) ("ftpScheduleDataRead: FD %d\n", ftpState->data.fd); + commSetSelect(ftpState->data.fd, + COMM_SELECT_READ, + ftpDataRead, + ftpState, + Config.Timeout.read); + commSetDefer(ftpState->data.fd, fwdCheckDeferRead, ftpState->entry); +} + + +static void ftpDataRead(int fd, void *data) { FtpStateData *ftpState = data; @@ -963,11 +976,8 @@ if (len < 0) { debug(50, ignoreErrno(errno) ? 3 : 1) ("ftpDataRead: read error: %s\n", xstrerror()); if (ignoreErrno(errno)) { - commSetSelect(fd, - COMM_SELECT_READ, - ftpDataRead, - data, - Config.Timeout.read); + assert(fd == ftpState->data.fd); + ftpScheduleDataRead(ftpState); } else { if (!ftpState->flags.http_header_sent && !ftpState->fwd->flags.ftp_pasv_failed && ftpState->flags.pasv_supported) { ftpState->fwd->flags.dont_retry = 0; /* this is a retryable error */ @@ -987,11 +997,8 @@ ftpState->data.offset = 0; } storeBufferFlush(entry); - commSetSelect(fd, - COMM_SELECT_READ, - ftpDataRead, - data, - Config.Timeout.read); + assert(fd == ftpState->data.fd); + ftpScheduleDataRead(ftpState); } } @@ -2176,12 +2183,7 @@ debug(9, 3) ("This is ftpReadList\n"); if (code == 125 || (code == 150 && ftpState->data.host)) { /* Begin data transfer */ - commSetSelect(ftpState->data.fd, - COMM_SELECT_READ, - ftpDataRead, - ftpState, - Config.Timeout.read); - commSetDefer(ftpState->data.fd, fwdCheckDeferRead, ftpState->entry); + ftpScheduleDataRead(ftpState); ftpState->state = READING_DATA; /* * Cancel the timeout on the Control socket and establish one @@ -2229,12 +2231,7 @@ if (code == 125 || (code == 150 && ftpState->data.host)) { /* Begin data transfer */ debug(9, 3) ("ftpReadRetr: reading data channel\n"); - commSetSelect(ftpState->data.fd, - COMM_SELECT_READ, - ftpDataRead, - ftpState, - Config.Timeout.read); - commSetDefer(ftpState->data.fd, fwdCheckDeferRead, ftpState->entry); + ftpScheduleDataRead(ftpState); ftpState->state = READING_DATA; /* * Cancel the timeout on the Control socket and establish one