--------------------- PatchSet 113 Date: 2002/11/01 17:43:35 Author: rbcollins Branch: esi Tag: (none) Log: introduce method Members: src/ESI.cc:1.1.2.21->1.1.2.22 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.21 retrieving revision 1.1.2.22 diff -u -r1.1.2.21 -r1.1.2.22 --- squid3/src/ESI.cc 1 Nov 2002 12:11:43 -0000 1.1.2.21 +++ squid3/src/ESI.cc 1 Nov 2002 17:43:35 -0000 1.1.2.22 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.21 2002/11/01 12:11:43 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.22 2002/11/01 17:43:35 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -181,8 +181,6 @@ return ((esiElement *)data)->process(dovars); } -struct esiInclude; -static void esiIncludeSubRequestDone (esiInclude *, esiStreamContext *, int); /* the types we have */ typedef enum { @@ -266,6 +264,7 @@ esiInclude(int attributes, const char **attr, esiContext *); void render(esiSegment *); esiProcessResult_t process (int dovars); + void subRequestDone (esiStreamContext *, bool); struct { int onerrorcontinue:1; /* on error return zero data */ int failed:1; /* Failed to process completely */ @@ -281,6 +280,7 @@ CBDATA_TYPE (esiInclude); static FREE esiIncludeFree; static esiElement * esiIncludeNew (int attributes, const char **attr, esiContext *); +static void esiIncludeSubRequestDone (esiInclude *, esiStreamContext *, int); /* esiRemove */ class esiRemove : public esiElement { @@ -2121,65 +2121,71 @@ void esiIncludeSubRequestDone(esiInclude *thisNode, esiStreamContext *stream, int success) { - assert (thisNode); - if (thisNode->flags.finished || thisNode->flags.failed) + thisNode->subRequestDone(stream, success ? true : false); +} + +void +esiInclude::subRequestDone (esiStreamContext *stream, bool success) +{ + assert (this); + if (flags.finished || flags.failed) /* Do nothing, we don't need the data */ return; - if (stream == thisNode->src) { + if (stream == src) { if (success) { /* copy the lead segment */ debug (86,3)("esiIncludeSubRequestDone: Src OK - include PASSED.\n"); - thisNode->srccontent = cbdataAlloc (esiSegment); - xmemcpy (thisNode->srccontent->buf, stream->localbuffer.buf, stream->localbuffer.len); - thisNode->srccontent->len = stream->localbuffer.len; - thisNode->srccontent->next = stream->localbuffer.next; + srccontent = cbdataAlloc (esiSegment); + xmemcpy (srccontent->buf, stream->localbuffer.buf, stream->localbuffer.len); + srccontent->len = stream->localbuffer.len; + srccontent->next = stream->localbuffer.next; stream->localbuffer.next = NULL; /* we're done! */ - thisNode->flags.finished = 1; + flags.finished = 1; } else { /* Fail if there is no alt being retrieved */ debug (86,3)("esiIncludeSubRequestDone: Src FAILED\n"); - if (!(thisNode->alt || thisNode->altcontent)) { + if (!(alt || altcontent)) { debug (86,3)("esiIncludeSubRequestDone: Include FAILED - No ALT\n"); - thisNode->flags.failed = 1; - } else if (thisNode->altcontent) { + flags.failed = 1; + } else if (altcontent) { debug (86,3)("esiIncludeSubRequestDone: Include PASSED - ALT already Complete\n"); /* ALT was already retrieved, we are done */ - thisNode->flags.finished = 1; + flags.finished = 1; } } - thisNode->src = NULL; - } else if (stream == thisNode->alt) { + src = NULL; + } else if (stream == alt) { if (success) { debug (86,3)("esiIncludeSubRequestDone: ALT OK.\n"); /* copy the lead segment */ - thisNode->altcontent = cbdataAlloc (esiSegment); - xmemcpy (thisNode->altcontent->buf, stream->localbuffer.buf, stream->localbuffer.len); - thisNode->altcontent->len = stream->localbuffer.len; - thisNode->altcontent->next = stream->localbuffer.next; + altcontent = cbdataAlloc (esiSegment); + xmemcpy (altcontent->buf, stream->localbuffer.buf, stream->localbuffer.len); + altcontent->len = stream->localbuffer.len; + altcontent->next = stream->localbuffer.next; stream->localbuffer.next = NULL; /* we're done! */ - if (!(thisNode->src || thisNode->srccontent)) { + if (!(src || srccontent)) { /* src already failed, kick ESI processor */ debug (86,3)("esiIncludeSubRequestDone: Include PASSED - SRC already failed.\n"); - thisNode->flags.finished = 1; + flags.finished = 1; } } else { - if (!(thisNode->src || thisNode->srccontent)) { + if (!(src || srccontent)) { debug (86,3)("esiIncludeSubRequestDone: ALT FAILED, Include FAILED - SRC already failed\n"); /* src already failed */ - thisNode->flags.failed = 1; + flags.failed = 1; } } - thisNode->alt = NULL; + alt = NULL; } else { fatal ("esiIncludeSubRequestDone: non-owned stream found!\n"); } - if (thisNode->flags.finished || thisNode->flags.failed) { + if (flags.finished || flags.failed) { /* Kick ESI Processor */ - debug (86,5)("esiInclude %p SubRequest %p completed, kicking processor , status %s\n", thisNode, stream, thisNode->flags.finished ? "OK" : "FAILED"); - assert (thisNode->context); - esiKick (thisNode->context); + debug (86,5)("esiInclude %p SubRequest %p completed, kicking processor , status %s\n", this, stream, flags.finished ? "OK" : "FAILED"); + assert (context); + esiKick (context); } }