--------------------- PatchSet 6298 Date: 2007/12/15 16:21:26 Author: chtsanti Branch: async-calls Tag: (none) Log: - Making comm_reads to use the new CommCalls interface - The FtpStateData::ftpReadControlReply adjusted to allow its use with CommCalls interface Members: src/ftp.cc:1.89.4.4->1.89.4.5 Index: squid3/src/ftp.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ftp.cc,v retrieving revision 1.89.4.4 retrieving revision 1.89.4.5 diff -u -r1.89.4.4 -r1.89.4.5 --- squid3/src/ftp.cc 29 Nov 2007 21:04:03 -0000 1.89.4.4 +++ squid3/src/ftp.cc 15 Dec 2007 16:21:26 -0000 1.89.4.5 @@ -1,5 +1,5 @@ /* - * $Id: ftp.cc,v 1.89.4.4 2007/11/29 21:04:03 rousskov Exp $ + * $Id: ftp.cc,v 1.89.4.5 2007/12/15 16:21:26 chtsanti Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -209,7 +209,7 @@ static IOCB dataReadWrapper; static PF ftpDataWrite; static PF ftpTimeout; - static IOCB ftpReadControlReply; + void ftpReadControlReply(const CommIoCbParams &io); static IOCB ftpWriteCommandCallback; static HttpReply *ftpAuthRequired(HttpRequest * request, const char *realm); static wordlist *ftpParseControlReply(char *, size_t, int *, size_t *); @@ -1703,7 +1703,10 @@ handleControlReply(); } else { /* XXX What about Config.Timeout.read? */ - comm_read(ctrl.fd, ctrl.buf + ctrl.offset, ctrl.size - ctrl.offset, ftpReadControlReply, this); + typedef CommCbMemFunT Dialer; + AsyncCall *reader=asyncCall(9, 5, "FtpStateData::ftpReadControlReply", + Dialer(this, &FtpStateData::ftpReadControlReply)); + comm_read(ctrl.fd, ctrl.buf + ctrl.offset, ctrl.size - ctrl.offset, reader); /* * Cancel the timeout on the Data socket (if any) and * establish one on the control socket. @@ -1717,40 +1720,39 @@ } } -void -FtpStateData::ftpReadControlReply(int fd, char *buf, size_t len, comm_err_t errflag, int xerrno, void *data) +void FtpStateData::ftpReadControlReply(const CommIoCbParams &io) { - FtpStateData *ftpState = (FtpStateData *)data; - StoreEntry *entry = ftpState->entry; - debugs(9, 5, "ftpReadControlReply: FD " << fd << ", Read " << len << " bytes"); +// FtpStateData *ftpState = (FtpStateData *)data; +// StoreEntry *entry = entry; + debugs(9, 5, "ftpReadControlReply: FD " << io.fd << ", Read " << io.size << " bytes"); - if (len > 0) { - kb_incr(&statCounter.server.all.kbytes_in, len); - kb_incr(&statCounter.server.ftp.kbytes_in, len); + if (io.size > 0) { + kb_incr(&statCounter.server.all.kbytes_in, io.size); + kb_incr(&statCounter.server.ftp.kbytes_in, io.size); } - if (errflag == COMM_ERR_CLOSING) + if (io.flag == COMM_ERR_CLOSING) return; if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { - ftpState->abortTransaction("entry aborted during control reply read"); + abortTransaction("entry aborted during control reply read"); return; } - assert(ftpState->ctrl.offset < ftpState->ctrl.size); + assert(ctrl.offset < ctrl.size); - if (errflag == COMM_OK && len > 0) { - fd_bytes(fd, len, FD_READ); + if (io.flag == COMM_OK && io.size > 0) { + fd_bytes(io.fd, io.size, FD_READ); } - if (errflag != COMM_OK || len < 0) { - debugs(50, ignoreErrno(xerrno) ? 3 : 1, "ftpReadControlReply: read error: " << xstrerr(xerrno)); + if (io.flag != COMM_OK || io.size < 0) { + debugs(50, ignoreErrno(io.xerrno) ? 3 : 1, "ftpReadControlReply: read error: " << xstrerr(io.xerrno)); - if (ignoreErrno(xerrno)) { - ftpState->scheduleReadControlReply(0); + if (ignoreErrno(io.xerrno)) { + scheduleReadControlReply(0); } else { - ftpState->failed(ERR_READ_ERROR, xerrno); + failed(ERR_READ_ERROR, io.xerrno); /* failed closes ctrl.fd and frees ftpState */ return; } @@ -1758,22 +1760,22 @@ return; } - if (len == 0) { + if (io.size == 0) { if (entry->store_status == STORE_PENDING) { - ftpState->failed(ERR_FTP_FAILURE, 0); + failed(ERR_FTP_FAILURE, 0); /* failed closes ctrl.fd and frees ftpState */ return; } /* XXX this may end up having to be serverComplete() .. */ - ftpState->abortTransaction("zero control reply read"); + abortTransaction("zero control reply read"); return; } - len += ftpState->ctrl.offset; - ftpState->ctrl.offset = len; - assert(len <= ftpState->ctrl.size); - ftpState->handleControlReply(); + unsigned int len =io.size + ctrl.offset; + ctrl.offset = len; + assert(len <= ctrl.size); + handleControlReply(); } void