--------------------- PatchSet 5029 Date: 2002/09/17 22:21:21 Author: rbcollins Branch: fixrange Tag: (none) Log: extract method on clientKeepAliveNextRequest Members: src/client_side.c:1.72.2.21->1.72.2.22 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.21 retrieving revision 1.72.2.22 diff -u -r1.72.2.21 -r1.72.2.22 --- squid/src/client_side.c 17 Sep 2002 22:09:43 -0000 1.72.2.21 +++ squid/src/client_side.c 17 Sep 2002 22:21:21 -0000 1.72.2.22 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.21 2002/09/17 22:09:43 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.22 2002/09/17 22:21:21 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -149,7 +149,8 @@ static int contextStartOfOutput(clientSocketContext *context); static void contextSendBody(clientSocketContext *context, HttpReply * rep,StoreIOBuffer bodyData); static void contextSendStartOfMessage(clientSocketContext *context, HttpReply * rep,StoreIOBuffer bodyData); - +static void connReadNextRequest (ConnStateData *conn); + clientStreamNode * getTail (clientSocketContext *context) { @@ -663,20 +664,38 @@ clientStreamDetach(node, http); } -/* - * clientWriteBodyComplete is called for MEM_CLIENT_SOCK_BUF's - * written directly to the client socket, versus copying to a MemBuf - * and going through comm_write_mbuf. Most non-range responses after - * the headers probably go through here. - */ static void clientWriteBodyComplete(int fd, char *buf, size_t size, int errflag, void *data) { + clientWriteComplete(fd, NULL, size, errflag, data); +} + +void +connReadNextRequest (ConnStateData *conn) +{ + debug(33, 5) ("clientKeepaliveNextRequest: FD %d reading next req\n", + conn->fd); + fd_note(conn->fd, "Waiting for next request"); /* - * NOTE: clientWriteComplete doesn't currently use its "buf" - * (second) argument, so we pass in NULL. + * Set the timeout BEFORE calling clientReadRequest(). + */ + commSetTimeout(conn->fd, Config.Timeout.persistent_request, + requestTimeout, conn); + /* + * CYGWIN has a problem and is blocking on read() requests when there + * is no data present. + * This hack may hit performance a little, but it's better than + * blocking!. + */ + conn->defer.until = 0; /* Kick it to read a new request */ +#ifdef _SQUID_CYGWIN_ + commSetSelect(conn->fd, COMM_SELECT_READ, clientReadRequest, conn, 0); +#else + clientReadRequest(conn->fd, conn); /* Read next request */ +#endif + /* + * Note, the FD may be closed at this point. */ - clientWriteComplete(fd, NULL, size, errflag, data); } static void @@ -686,32 +705,10 @@ ConnStateData *conn = http->conn; debug(33, 3) ("clientKeepaliveNextRequest: FD %d\n", conn->fd); - conn->defer.until = 0; /* Kick it to read a new request */ cbdataFree(context); - if ((context = connGetCurrentContext(conn)) == NULL) { - debug(33, 5) ("clientKeepaliveNextRequest: FD %d reading next req\n", - conn->fd); - fd_note(conn->fd, "Waiting for next request"); - /* - * Set the timeout BEFORE calling clientReadRequest(). - */ - commSetTimeout(conn->fd, Config.Timeout.persistent_request, - requestTimeout, conn); - /* - * CYGWIN has a problem and is blocking on read() requests when there - * is no data present. - * This hack may hit performance a little, but it's better than - * blocking!. - */ -#ifdef _SQUID_CYGWIN_ - commSetSelect(conn->fd, COMM_SELECT_READ, clientReadRequest, conn, 0); -#else - clientReadRequest(conn->fd, conn); /* Read next request */ -#endif - /* - * Note, the FD may be closed at this point. - */ - } else { + if ((context = connGetCurrentContext(conn)) == NULL) + connReadNextRequest (conn); + else { debug(33, 2) ("clientKeepaliveNextRequest: FD %d Sending next\n", conn->fd); /* If the client stream is waiting on a socket write to occur, then */