--------------------- PatchSet 7134 Date: 2005/10/26 04:49:31 Author: adri Branch: tidyup_deferred_reads Tag: (none) Log: remove the comm_read() stuff, I didn't have to use it! Members: src/comm.c:1.18.6.5.6.4->1.18.6.5.6.5 src/structs.h:1.48.2.34.4.8->1.48.2.34.4.9 src/typedefs.h:1.25.6.6.12.4->1.25.6.6.12.5 Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.18.6.5.6.4 retrieving revision 1.18.6.5.6.5 diff -u -r1.18.6.5.6.4 -r1.18.6.5.6.5 --- squid/src/comm.c 13 Oct 2005 09:14:35 -0000 1.18.6.5.6.4 +++ squid/src/comm.c 26 Oct 2005 04:49:31 -0000 1.18.6.5.6.5 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.18.6.5.6.4 2005/10/13 09:14:35 adri Exp $ + * $Id: comm.c,v 1.18.6.5.6.5 2005/10/26 04:49:31 adri Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -962,91 +962,6 @@ comm_write(fd, mb.buf, mb.size, handler, handler_data, memBufFreeFunc(&mb)); } -static void -commReadStateCallbackAndFree(int fd, int code) -{ - CommReadStateData state = fd_table[fd].read_state; - CWCB *callback = state.handler; - void *data = state.handler_data; - size_t readlen = state.readlen; - void *buf = state.buf; - - if (callback == NULL) - return; - - fd_table[fd].read_state.handler = NULL; - - if (callback && cbdataValid(data)) - callback(fd, buf, readlen, code, data); - cbdataUnlock(data); -} - -void -commHandleRead(int fd, void *data) -{ - CommReadStateData *state = data; - int len = 0; - - debug(5, 5) ("commHandleRead: FD %d:\n", fd); - - len = FD_READ_METHOD(fd, state->buf, state->size); - debug(5, 5) ("commHandleRead: read() returns %d\n", len); - statCounter.syscalls.sock.reads++; - fd_table[fd].read_state.readlen = len; - if (len > 0) { - fd_bytes(fd, len, FD_READ); - /* XXX delay pools? */ - kb_incr(&statCounter.server.all.kbytes_in, len); - commReadStateCallbackAndFree(fd, COMM_OK); - return; - } else if (len < 0) { - debug(5, ignoreErrno(errno) ? 3: 1) - ("commHandleRead: FD %d: read failure: %s\n", fd, xstrerror()); - if (! ignoreErrno(errno)) { - commReadStateCallbackAndFree(fd, COMM_ERROR); - comm_close(fd); - return; - } - } else if (len == 0) { - commReadStateCallbackAndFree(fd, COMM_ERR_CLOSING); - comm_close(fd); - return; - } - assert(1==0); /* XXX shouldn't ever get here */ -} - - -/* - * Schedule a read - * - * + This shouldn't be done on a closing FD - * + The comm handler will be called when the FD is ready, regardless - * of error condition or not. The handler should check that - * the result was COMM_OK and if not prepare to have the FD closed. - * comm_close() will be called after the handler completes in the - * case of an error. - */ -void -comm_read(int fd, char *buf, int size, CRCB *handler, void *handler_data) -{ - CommReadStateData *state = &fd_table[fd].read_state; - - /* make sure we're not reading anything and not closing */ - assert(fd_table[fd].flags.open == 1); - assert(! fd_table[fd].flags.closing); - assert(fd_table[fd].read_state.handler == NULL); - - debug (5, 4) ("comm_read: queueing read for FD %d\n", fd); - - state->buf = (char *) buf; - state->size = size; - state->handler = handler; - state->handler_data = handler_data; - cbdataLock(handler_data); - commSetSelect(fd, COMM_SELECT_READ, commHandleRead, state, 0); -} - - /* * hm, this might be too general-purpose for all the places we'd * like to use it. Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.2.34.4.8 retrieving revision 1.48.2.34.4.9 diff -u -r1.48.2.34.4.8 -r1.48.2.34.4.9 --- squid/src/structs.h 13 Oct 2005 09:14:35 -0000 1.48.2.34.4.8 +++ squid/src/structs.h 26 Oct 2005 04:49:31 -0000 1.48.2.34.4.9 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.2.34.4.8 2005/10/13 09:14:35 adri Exp $ + * $Id: structs.h,v 1.48.2.34.4.9 2005/10/26 04:49:31 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -772,15 +772,6 @@ FREE *free_func; }; -struct _CommReadStateData { - char *buf; - size_t size; - size_t readlen; - int flags; - CRCB *handler; - void *handler_data; -}; - struct _fde { unsigned int type; u_short local_port; @@ -825,7 +816,6 @@ DEFER *defer_check; /* check if we should defer read */ void *defer_data; CommWriteStateData rwstate; /* State data for comm_write */ - CommReadStateData read_state; /* State data for comm_read */ READ_HANDLER *read_method; WRITE_HANDLER *write_method; #if USE_SSL Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.25.6.6.12.4 retrieving revision 1.25.6.6.12.5 diff -u -r1.25.6.6.12.4 -r1.25.6.6.12.5 --- squid/src/typedefs.h 7 Oct 2005 03:23:11 -0000 1.25.6.6.12.4 +++ squid/src/typedefs.h 26 Oct 2005 04:49:31 -0000 1.25.6.6.12.5 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.25.6.6.12.4 2005/10/07 03:23:11 adri Exp $ + * $Id: typedefs.h,v 1.25.6.6.12.5 2005/10/26 04:49:31 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -173,7 +173,6 @@ typedef struct _cachemgr_passwd cachemgr_passwd; typedef struct _refresh_t refresh_t; typedef struct _CommWriteStateData CommWriteStateData; -typedef struct _CommReadStateData CommReadStateData; typedef struct _ErrorState ErrorState; typedef struct _dlink_node dlink_node; typedef struct _dlink_list dlink_list;