--------------------- PatchSet 5027 Date: 2002/09/17 21:51:22 Author: rbcollins Branch: fixrange Tag: (none) Log: increase readability Members: src/client_side.c:1.72.2.19->1.72.2.20 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.19 retrieving revision 1.72.2.20 diff -u -r1.72.2.19 -r1.72.2.20 --- squid/src/client_side.c 17 Sep 2002 21:35:52 -0000 1.72.2.19 +++ squid/src/client_side.c 17 Sep 2002 21:51:22 -0000 1.72.2.20 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.19 2002/09/17 21:35:52 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.20 2002/09/17 21:51:22 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -143,6 +143,8 @@ static void connEmptyOSReadBuffers(int fd); static int connIsUsable(ConnStateData *conn); static clientSocketContext *connGetCurrentContext(ConnStateData *conn); +static void contextDeferRecipientForLater(clientSocketContext *context, clientStreamNode * node, HttpReply * rep, StoreIOBuffer recievedData); + clientStreamNode * getTail (clientSocketContext *context) @@ -527,6 +529,26 @@ return conn->currentobject; } +void +contextDeferRecipientForLater(clientSocketContext *context, clientStreamNode * node, HttpReply * rep, StoreIOBuffer recievedData) +{ + debug(33, 2) ("clientSocketRecipient: Deferring %s\n", context->http->uri); + assert (context->flags.deferred == 0); + context->flags.deferred = 1; + context->deferredparams.node = node; + context->deferredparams.rep = rep; + context->deferredparams.queuedBuffer = recievedData; + return; +} + +int +responseFinishedOrFailed(HttpReply * rep, StoreIOBuffer recievedData) +{ + if (rep == NULL && recievedData.data == NULL && recievedData.length == 0) + return 1; + return 0; +} + /* * Write a chunk of data to a client socket. If the reply is present, send the reply headers down the wire too, * and clean them up when finished. @@ -543,7 +565,8 @@ clientSocketContext *context; /* Test preconditions */ assert(node != NULL); - /* TODO: handle this rather than asserting - it should only ever happen if we cause an abort and + /* TODO: handle this rather than asserting + * - it should only ever happen if we cause an abort and * the callback chain loops back to here, so we can simply return. * However, that itself shouldn't happen, so it stays as an assert for now. */ @@ -554,23 +577,19 @@ assert(connIsUsable(http->conn)); fd = http->conn->fd; if (connGetCurrentContext(http->conn) != context) { - /* there is another object in progress, defer this one */ - debug(33, 2) ("clientSocketRecipient: Deferring %s\n", http->uri); - context->flags.deferred = 1; - context->deferredparams.node = node; - context->deferredparams.rep = rep; - context->deferredparams.queuedBuffer = recievedData; + contextDeferRecipientForLater (context, node, rep, recievedData); return; } /* EOF / Read error / aborted entry */ - if (rep == NULL && recievedData.data == NULL && recievedData.length == 0) { + if (responseFinishedOrFailed(rep, recievedData)) { clientWriteComplete(fd, NULL, 0, COMM_OK, context); return; } /* trivial case */ if (http->out.offset != 0) { assert(rep == NULL); - /* Avoid copying to MemBuf if we know "rep" is NULL, and we only have a body */ + /* Avoid copying to MemBuf if we know "rep" is NULL, + * and we only have a body */ http->out.offset += recievedData.length; comm_write(fd, recievedData.data, recievedData.length, clientWriteBodyComplete, context, NULL);