--------------------- PatchSet 5010 Date: 2002/09/17 10:51:16 Author: rbcollins Branch: fixrange Tag: (none) Log: introduce parameter obejct to clients stram callbacks Members: src/clientStream.c:1.2.8.9->1.2.8.10 src/clientStream.h:1.1.2.10->1.1.2.11 src/client_side.c:1.72.2.3->1.72.2.4 Index: squid/src/clientStream.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/clientStream.c,v retrieving revision 1.2.8.9 retrieving revision 1.2.8.10 diff -u -r1.2.8.9 -r1.2.8.10 --- squid/src/clientStream.c 17 Sep 2002 10:34:36 -0000 1.2.8.9 +++ squid/src/clientStream.c 17 Sep 2002 10:51:16 -0000 1.2.8.10 @@ -1,6 +1,6 @@ /* - * $Id: clientStream.c,v 1.2.8.9 2002/09/17 10:34:36 rbcollins Exp $ + * $Id: clientStream.c,v 1.2.8.10 2002/09/17 10:51:16 rbcollins Exp $ * * DEBUG: section 87 Client-side Stream routines. * AUTHOR: Robert Collins @@ -157,8 +157,7 @@ assert(list->head); temp = clientStreamNew(func, callback, detach, status, data); temp->head = list; - debug(87, - 3) + debug(87, 3) ("clientStreamInsertHead: Inserted node %p with data %p after head\n", temp, data); dlinkAddAfter(temp, &temp->node, list->head, list); @@ -179,7 +178,7 @@ debug(87, 3) ("clientStreamCallback: Calling %p with cbdata %p from node %p\n", next->callback, next->data, this); - next->callback(next, http, rep, replyBuffer.data, replyBuffer.flags.error ? -1 : replyBuffer.length); + next->callback(next, http, rep, replyBuffer); } /* Index: squid/src/clientStream.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/clientStream.h,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -r1.1.2.10 -r1.1.2.11 --- squid/src/clientStream.h 17 Sep 2002 10:34:37 -0000 1.1.2.10 +++ squid/src/clientStream.h 17 Sep 2002 10:51:17 -0000 1.1.2.11 @@ -1,6 +1,6 @@ /* - * $Id: clientStream.h,v 1.1.2.10 2002/09/17 10:34:37 rbcollins Exp $ + * $Id: clientStream.h,v 1.1.2.11 2002/09/17 10:51:17 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -38,7 +38,7 @@ typedef struct _clientStreamNode clientStreamNode; /* client stream read callback */ -typedef void CSCB(clientStreamNode *, clientHttpRequest *, HttpReply *, const char *, ssize_t); +typedef void CSCB(clientStreamNode *, clientHttpRequest *, HttpReply *, StoreIOBuffer); /* client stream read */ typedef void CSR(clientStreamNode *, clientHttpRequest *); /* client stream detach */ Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.3 retrieving revision 1.72.2.4 diff -u -r1.72.2.3 -r1.72.2.4 --- squid/src/client_side.c 17 Sep 2002 10:34:37 -0000 1.72.2.3 +++ squid/src/client_side.c 17 Sep 2002 10:51:17 -0000 1.72.2.4 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.3 2002/09/17 10:34:37 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.4 2002/09/17 10:51:17 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -137,7 +137,7 @@ struct { clientStreamNode *node; HttpReply *rep; - const char *body_data; + char *body_data; ssize_t body_size; } deferredparams; } clientSocketContext; @@ -483,7 +483,7 @@ */ static void clientSocketRecipient(clientStreamNode * node, clientHttpRequest * http, - HttpReply * rep, const char *body_data, ssize_t body_size) + HttpReply * rep, StoreIOBuffer recievedData) { int fd; clientSocketContext *context; @@ -505,12 +505,12 @@ context->flags.deferred = 1; context->deferredparams.node = node; context->deferredparams.rep = rep; - context->deferredparams.body_data = body_data; - context->deferredparams.body_size = body_size; + context->deferredparams.body_data = recievedData.data; + context->deferredparams.body_size = recievedData.length; return; } /* EOF / Read error / aborted entry */ - if (rep == NULL && body_data == NULL && body_size == 0) { + if (rep == NULL && recievedData.data == NULL && recievedData.length == 0) { clientWriteComplete(fd, NULL, 0, COMM_OK, context); return; } @@ -518,15 +518,15 @@ if (http->out.offset != 0) { assert(rep == NULL); /* Avoid copying to MemBuf if we know "rep" is NULL, and we only have a body */ - http->out.offset += body_size; - comm_write(fd, body_data, body_size, clientWriteBodyComplete, context, + http->out.offset += recievedData.length; + comm_write(fd, recievedData.data, recievedData.length, clientWriteBodyComplete, context, NULL); /* NULL because its a static buffer */ return; } else { MemBuf mb; /* write headers and/or body if any */ - assert(rep || (body_data && body_size)); + assert(rep || ( recievedData.data && recievedData.length)); /* init mb; put status line and headers if any */ if (rep) { mb = httpReplyPack(rep); @@ -539,9 +539,9 @@ } else { memBufDefInit(&mb); } - if (body_data && body_size) { - http->out.offset += body_size; - memBufAppend(&mb, body_data, body_size); + if ( recievedData.data && recievedData.length) { + http->out.offset += recievedData.length; + memBufAppend(&mb, recievedData.data, recievedData.length); } /* write */ comm_write_mbuf(fd, mb, clientWriteComplete, context); @@ -628,11 +628,12 @@ /* If the client stream is waiting on a socket write to occur, then */ if (context->flags.deferred) { /* NO data is allowed to have been sent */ + StoreIOBuffer pushBuffer = EMPTYIOBUFFER; assert(http->out.size == 0); + pushBuffer.data = context->deferredparams.body_data; + pushBuffer.length = context->deferredparams.body_size; clientSocketRecipient(context->deferredparams.node, http, - context->deferredparams.rep, - context->deferredparams.body_data, - context->deferredparams.body_size); + context->deferredparams.rep, pushBuffer); } /* otherwise, the request is still active in a callbacksomewhere, * and we are done