--------------------- PatchSet 5346 Date: 2002/10/12 04:43:01 Author: adri Branch: commloops Tag: (none) Log: * change around the read check function to indicate it works on _callbacks_, not the read itself * write a function to return whether a read has been scheduled (not a completed read) * update pconn to use the former (just change the name) Members: src/comm.c:1.21.4.26->1.21.4.27 src/comm.h:1.1.2.4->1.1.2.5 src/pconn.c:1.6.32.4->1.6.32.5 Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.21.4.26 retrieving revision 1.21.4.27 diff -u -r1.21.4.26 -r1.21.4.27 --- squid/src/comm.c 12 Oct 2002 00:15:36 -0000 1.21.4.26 +++ squid/src/comm.c 12 Oct 2002 04:43:01 -0000 1.21.4.27 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.21.4.26 2002/10/12 00:15:36 adri Exp $ + * $Id: comm.c,v 1.21.4.27 2002/10/12 04:43:01 adri Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -471,7 +471,7 @@ * Assumptions: the fd is open (ie, its not closing) */ int -comm_has_pending_read(int fd) +comm_has_pending_read_callback(int fd) { dlink_node *node; CommCallbackData *cd; @@ -499,6 +499,20 @@ } /* + * return whether a file descriptor has a read handler + * + * Assumptions: the fd is open + */ +int +comm_has_pending_read(int fd) +{ + assert(fd_table[fd].flags.open == 1); + assert(fdc_table[fd].active == 1); + + return (fdc_table[fd].read.handler != NULL); +} + +/* * Cancel a pending read. Assert that we have the right parameters, * and that there are no pending read events! */ @@ -511,7 +525,7 @@ assert(fdc_table[fd].read.handler == callback); assert(fdc_table[fd].read.handler_data == data); - assert(!comm_has_pending_read(fd)); + assert(!comm_has_pending_read_callback(fd)); /* Ok, we can be reasonably sure we won't lose any data here! */ Index: squid/src/comm.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/comm.h,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid/src/comm.h 9 Oct 2002 09:55:38 -0000 1.1.2.4 +++ squid/src/comm.h 12 Oct 2002 04:43:01 -0000 1.1.2.5 @@ -6,6 +6,7 @@ /* fill sb with up to length data from fd */ extern void comm_fill_immediate(int fd, StoreIOBuffer sb, IOFCB *callback, void *data); +extern int comm_has_pending_read_callback(int fd); extern int comm_has_pending_read(int fd); extern void comm_read_cancel(int fd, IOCB *callback, void *data); extern void fdc_open(int fd, unsigned int type, char *desc); Index: squid/src/pconn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/pconn.c,v retrieving revision 1.6.32.4 retrieving revision 1.6.32.5 diff -u -r1.6.32.4 -r1.6.32.5 --- squid/src/pconn.c 9 Oct 2002 13:46:28 -0000 1.6.32.4 +++ squid/src/pconn.c 12 Oct 2002 04:43:01 -0000 1.6.32.5 @@ -1,6 +1,6 @@ /* - * $Id: pconn.c,v 1.6.32.4 2002/10/09 13:46:28 adri Exp $ + * $Id: pconn.c,v 1.6.32.5 2002/10/12 04:43:01 adri Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -276,8 +276,8 @@ assert(p->nfds > 0); for (i = 0; i < p->nfds; i++) { fd = p->fds[0]; - /* If there are pending reads - we're about to close it, so don't issue it! */ - if (!comm_has_pending_read(fd)) { + /* If there are pending read callbacks - we're about to close it, so don't issue it! */ + if (!comm_has_pending_read_callback(fd)) { pconnRemoveFD(p, fd); comm_read_cancel(fd, pconnRead, p); commSetTimeout(fd, -1, NULL, NULL);