--------------------- PatchSet 127 Date: 2002/11/04 11:44:24 Author: rbcollins Branch: esi Tag: (none) Log: step towards three-step processing Members: src/ESI.cc:1.1.2.34->1.1.2.35 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.34 retrieving revision 1.1.2.35 diff -u -r1.1.2.34 -r1.1.2.35 --- squid3/src/ESI.cc 4 Nov 2002 10:42:16 -0000 1.1.2.34 +++ squid3/src/ESI.cc 4 Nov 2002 11:44:24 -0000 1.1.2.35 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.34 2002/11/04 10:42:16 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.35 2002/11/04 11:44:24 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -448,6 +448,7 @@ void fail (); void freeResources(); void fixupOutboundTail(); + size_t send (clientStreamNode *thisNode, clientHttpRequest *http); }; CBDATA_TYPE(esiContext); @@ -464,7 +465,6 @@ /* Local functions */ /* esiContext */ static esiContext *esiContextNew(HttpReply *, clientStreamNode *, clientHttpRequest *); -static size_t esiSend (clientStreamNode *thisNode, esiContext *,clientHttpRequest *http); static esiProcessResult_t esiProcess (esiContext *); /* esiStreamContext */ static FREE esiStreamContextFree; @@ -567,7 +567,7 @@ tree->render(outboundtail); fixupOutboundTail(); /* Is there data to send? */ - if (esiSend (thisNode, this, http)) { + if (send (thisNode, http)) { /* some data was sent. we're finished until the next read */ --flags.kicked; return ESI_KICK_SENT; @@ -708,76 +708,76 @@ * Returns 0 if nothing was sent. Non-zero if data was sent. */ size_t -esiSend (clientStreamNode *thisNode, esiContext *context, clientHttpRequest *http) +esiContext::send (clientStreamNode *thisNode, clientHttpRequest *http) { /* send any processed data */ /* trim leading empty buffers ? */ - while (context->outbound && context->outbound->next && !context->outbound->len) { - esiSegment *temp = context->outbound->next; - cbdataFree (context->outbound); - context->outbound = temp; + while (outbound && outbound->next && !outbound->len) { + esiSegment *temp = outbound->next; + cbdataFree (outbound); + outbound = temp; } - if (!context->flags.clientwantsdata) { + if (!flags.clientwantsdata) { debug (86,5)("esiSend: Client does not want data - not sending anything\n"); return 0; } - if (context->flags.oktosend && (context->rep || (context->outbound && - context->outbound->len && (context->outbound_offset <= context->outbound->len)))) { + if (flags.oktosend && (rep || (outbound && + outbound->len && (outbound_offset <= outbound->len)))) { /* Yes! Send it without asking for more upstream */ /* memcopying because the client provided the buffer */ /* TODO: skip data until pos == next->readoff; */ clientStreamNode *next; size_t len = 0; - HttpReply *rep; - assert (thisNode->data == context); + assert (thisNode->data == this); next = thisNode->next(); - cbdataReference (context); - if (context->outbound) - len = next->readBuffer.length < (context->outbound->len - context->outbound_offset) ? - next->readBuffer.length : (context->outbound->len - context->outbound_offset); + cbdataReference (this); + if (outbound) + len = next->readBuffer.length < (outbound->len - outbound_offset) ? + next->readBuffer.length : (outbound->len - outbound_offset); /* prevent corruption on range requests, even though we don't support them yet */ - assert (context->pos == next->readBuffer.offset); + assert (pos == next->readBuffer.offset); /* We must send data or a reply */ - assert (len != 0 || context->rep != NULL); + assert (len != 0 || rep != NULL); if (len) { - xmemcpy (next->readBuffer.data, &context->outbound->buf[context->outbound_offset], len); - if (len + context->outbound_offset == context->outbound->len) { - esiSegment *temp = context->outbound->next; + xmemcpy (next->readBuffer.data, &outbound->buf[outbound_offset], len); + if (len + outbound_offset == outbound->len) { + esiSegment *temp = outbound->next; /* remove the used buffer */ - context->outbound_offset = 0; - cbdataFree (context->outbound); - context->outbound = temp; + outbound_offset = 0; + cbdataFree (outbound); + outbound = temp; } - context->pos += len; - if (!context->outbound) - context->outboundtail = NULL; + pos += len; + if (!outbound) + outboundtail = NULL; /* trim leading empty buffers ? */ - while (context->outbound && context->outbound->next && !context->outbound->len) { - esiSegment *temp = context->outbound->next; - cbdataFree (context->outbound); - context->outbound = temp; + while (outbound && outbound->next && !outbound->len) { + esiSegment *temp = outbound->next; + cbdataFree (outbound); + outbound = temp; } } - context->flags.clientwantsdata = 0; + flags.clientwantsdata = 0; debug (86,5)("esiSend: Client no longer wants data \n"); /* Deal with re-entrancy */ - rep = context->rep; - context->rep = NULL; /* freed downstream */ - if (rep && context->varState) - context->varState->buildVary (rep); + HttpReply *temprep = rep; + rep = NULL; /* freed downstream */ + if (temprep && varState) + varState->buildVary (temprep); { StoreIOBuffer tempBuffer = EMPTYIOBUFFER; tempBuffer.length = len; - tempBuffer.offset = context->pos - len; + tempBuffer.offset = pos - len; tempBuffer.data = next->readBuffer.data; - clientStreamCallback (thisNode, http, rep, tempBuffer); + clientStreamCallback (thisNode, http, temprep, tempBuffer); } if (len == 0) len = 1; /* tell the caller we sent something (because we sent headers */ - cbdataReferenceDone (context); + esiContext *temp = this; + cbdataReferenceDone (temp); debug (86,5)("esiSend returning %d\n",len); return len; } @@ -1460,7 +1460,7 @@ /* the esiCode now thinks that the error is the outbound, * and all processing has finished. */ /* Send as much as we can */ - assert (esiSend (thisNode, this, http)); + assert (send (thisNode, http)); /* don't cancel anything. The stream nodes will clean up after * themselves when the reply is freed - and we don't know what to * clean anyway.