--------------------- PatchSet 5320 Date: 2002/10/09 08:40:28 Author: adri Branch: commloops Tag: (none) Log: Convert over the helper management routines to use comm_read(). Members: src/helper.c:1.16.18.2->1.16.18.3 Index: squid/src/helper.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/helper.c,v retrieving revision 1.16.18.2 retrieving revision 1.16.18.3 diff -u -r1.16.18.2 -r1.16.18.3 --- squid/src/helper.c 6 Oct 2002 07:12:20 -0000 1.16.18.2 +++ squid/src/helper.c 9 Oct 2002 08:40:28 -0000 1.16.18.3 @@ -1,6 +1,6 @@ /* - * $Id: helper.c,v 1.16.18.2 2002/10/06 07:12:20 rbcollins Exp $ + * $Id: helper.c,v 1.16.18.3 2002/10/09 08:40:28 adri Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Harvest Derived? @@ -37,8 +37,8 @@ #define HELPER_MAX_ARGS 64 -static PF helperHandleRead; -static PF helperStatefulHandleRead; +static IOCB helperHandleRead; +static IOCB helperStatefulHandleRead; static PF helperServerFree; static PF helperStatefulServerFree; static void Enqueue(helper * hlp, helper_request *); @@ -696,21 +696,19 @@ static void -helperHandleRead(int fd, void *data) +helperHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) { - int len; char *t = NULL; helper_server *srv = data; helper_request *r; helper *hlp = srv->parent; assert(fd == srv->rfd); assert(cbdataReferenceValid(data)); - statCounter.syscalls.sock.reads++; - len = FD_READ_METHOD(fd, srv->buf + srv->offset, srv->buf_sz - srv->offset); - fd_bytes(fd, len, FD_READ); + + debug(84, 5) ("helperHandleRead: %d bytes from %s #%d.\n", - len, hlp->id_name, srv->index + 1); - if (len <= 0) { + (int)len, hlp->id_name, srv->index + 1); + if (flag != COMM_OK || len <= 0) { if (len < 0) debug(50, 1) ("helperHandleRead: FD %d read: %s\n", fd, xstrerror()); comm_close(fd); @@ -722,7 +720,7 @@ if (r == NULL) { /* someone spoke without being spoken to */ debug(84, 1) ("helperHandleRead: unexpected read from %s #%d, %d bytes\n", - hlp->id_name, srv->index + 1, len); + hlp->id_name, srv->index + 1, (int)len); srv->offset = 0; } else if ((t = strchr(srv->buf, '\n'))) { /* end of reply found */ @@ -751,26 +749,24 @@ } else helperKickQueue(hlp); } else { - commSetSelect(srv->rfd, COMM_SELECT_READ, helperHandleRead, srv, 0); + comm_read(fd, srv->buf + srv->offset, srv->buf_sz - srv->offset, helperHandleRead, data); } } static void -helperStatefulHandleRead(int fd, void *data) +helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) { - int len; char *t = NULL; helper_stateful_server *srv = data; helper_stateful_request *r; statefulhelper *hlp = srv->parent; assert(fd == srv->rfd); assert(cbdataReferenceValid(data)); - statCounter.syscalls.sock.reads++; - len = FD_READ_METHOD(fd, srv->buf + srv->offset, srv->buf_sz - srv->offset); - fd_bytes(fd, len, FD_READ); + + debug(84, 5) ("helperStatefulHandleRead: %d bytes from %s #%d.\n", - len, hlp->id_name, srv->index + 1); - if (len <= 0) { + (int)len, hlp->id_name, srv->index + 1); + if (flag != COMM_OK || len <= 0) { if (len < 0) debug(50, 1) ("helperStatefulHandleRead: FD %d read: %s\n", fd, xstrerror()); comm_close(fd); @@ -782,7 +778,7 @@ if (r == NULL) { /* someone spoke without being spoken to */ debug(84, 1) ("helperStatefulHandleRead: unexpected read from %s #%d, %d bytes\n", - hlp->id_name, srv->index + 1, len); + hlp->id_name, srv->index + 1, (int)len); srv->offset = 0; } else if ((t = strchr(srv->buf, '\n'))) { /* end of reply found */ @@ -851,7 +847,8 @@ helperStatefulKickQueue(hlp); } } else { - commSetSelect(srv->rfd, COMM_SELECT_READ, helperStatefulHandleRead, srv, 0); + comm_read(srv->rfd, srv->buf + srv->offset, srv->buf_sz - srv->offset, + helperStatefulHandleRead, srv); } } @@ -1023,10 +1020,7 @@ NULL, /* Handler */ NULL, /* Handler-data */ NULL); /* free */ - commSetSelect(srv->rfd, - COMM_SELECT_READ, - helperHandleRead, - srv, 0); + comm_read(srv->rfd, srv->buf + srv->offset, srv->buf_sz - srv->offset, helperHandleRead, srv); debug(84, 5) ("helperDispatch: Request sent to %s #%d, %d bytes\n", hlp->id_name, srv->index + 1, (int) strlen(r->buf)); srv->stats.uses++; @@ -1077,10 +1071,8 @@ NULL, /* Handler */ NULL, /* Handler-data */ NULL); /* free */ - commSetSelect(srv->rfd, - COMM_SELECT_READ, - helperStatefulHandleRead, - srv, 0); + comm_read(srv->rfd, srv->buf + srv->offset, srv->buf_sz - srv->offset, + helperStatefulHandleRead, srv); debug(84, 5) ("helperStatefulDispatch: Request sent to %s #%d, %d bytes\n", hlp->id_name, srv->index + 1, (int) strlen(r->buf)); srv->stats.uses++;