--------------------- PatchSet 458 Date: 2002/12/22 05:10:31 Author: rbcollins Branch: esi Tag: (none) Log: and the rest of the leaks Members: src/ESI.cc:1.1.2.69->1.1.2.70 src/ESIElement.h:1.1.2.7->1.1.2.8 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.69 retrieving revision 1.1.2.70 diff -u -r1.1.2.69 -r1.1.2.70 --- squid3/src/ESI.cc 21 Dec 2002 21:02:33 -0000 1.1.2.69 +++ squid3/src/ESI.cc 22 Dec 2002 05:10:31 -0000 1.1.2.70 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.69 2002/12/21 21:02:33 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.70 2002/12/22 05:10:31 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -196,6 +196,7 @@ Pointer makeCacheable() const; void render(ESISegment *); + void finish(); private: static MemPool *pool; }; @@ -220,6 +221,7 @@ int donevars:1; } flags; esiVarState *varState; + void finish(); private: static MemPool *pool; esiLiteral(esiLiteral const &); @@ -253,6 +255,7 @@ struct { int dovars:1; /* for esiVar */ } flags; + void finish(); protected: esiSequence(esiSequence const &); private: @@ -291,6 +294,7 @@ esiContext *context; char *srcurl, *alturl; void fail(esiStreamContext *); + void finish(); private: static MemPool *Pool; esiTreeParentPtr parent; @@ -313,6 +317,7 @@ void render(ESISegment *); bool addElement (ESIElement::Pointer); Pointer makeCacheable() const; + void finish(); }; CBDATA_TYPE (esiRemove); static FREE esiRemoveFree; @@ -358,6 +363,7 @@ int attemptfailed:1; /* The attempt branch failed */ int exceptfailed:1; /* the except branch failed */ } flags; + void finish(); private: static MemPool *Pool; void notifyParent(); @@ -402,6 +408,7 @@ int elementcount; int chosenelement; ESIElement::Pointer otherwise; + void finish(); private: static MemPool *Pool; esiChoose(esiChoose const &); @@ -459,6 +466,8 @@ void addStackElement (ESIElement::Pointer element); void addLiteral (const XML_Char *s, int len); + + void finishChildren (); clientStreamNode *thisNode; /* our stream node */ clientHttpRequest *http; /* the request we are processing. HMM: cbdataReferencing this will result @@ -503,6 +512,7 @@ bool inited() const; ParserState(); void freeResources(); + void popAll(); private: bool inited_; } parserState; /* todo factor this off somewhere else; */ @@ -511,6 +521,7 @@ esiKick_t kick (); RefCount cbdataLocker; + bool failed() const {return flags.error != 0;} private: CBDATA_CLASS(esiContext); void fail (); @@ -929,6 +940,14 @@ return len; } +void +esiContext::finishChildren() +{ + if (tree.getRaw()) + tree->finish(); + tree = NULL; +} + /* Detach event from a client Stream */ void esiStreamDetach (clientStreamNode *thisNode, clientHttpRequest *http) @@ -944,7 +963,7 @@ /* if we have pending callbacks (from subincludes), tell them we're done. */ context->thisNode = NULL; context->flags.detached = 1; - context->tree = NULL; + context->finishChildren(); /* HACK for parser stack not being emptied */ context->parserState.stack[0] = NULL; /* allow refcount logic to trigger */ @@ -1194,8 +1213,10 @@ { /* Put on the stack to allow skipping of 'invalid' markup */ assert (parserState.stackdepth <11); + assert (!failed()); + debug (86,5)("esiContext::addStackElement: About to add ESI Node %p\n", element.getRaw()); if (!parserState.top()->addElement(element)) { - debug (86,1)("esiProcess: failed to add esi node, probable error in ESI template\n"); + debug (86,1)("esiContext::addStackElement: failed to add esi node, probable error in ESI template\n"); flags.error = 1; } else { /* added ok, push onto the stack */ @@ -1218,7 +1239,7 @@ debug (86, 5)("esiExpatStart: element '%s' with %d tags\n", el, specifiedattcount); - if (context->flags.error) + if (context->failed()) /* waiting for expat to finish the buffer we gave it */ return; @@ -1341,6 +1362,8 @@ { XML_Parser parser = data; esiContext *context = (esiContext *)XML_GetUserData(parser); + if (context->failed()) + return; /* handle and skipped data */ context->addLiteral (s, len); } @@ -1350,6 +1373,8 @@ { XML_Parser parser = data; esiContext *context = (esiContext *)XML_GetUserData(parser); + if (context->failed()) + return; if (!strncmp(s, "esi",3)) { XML_Parser p; debug (86,5)("esiExpatComment: ESI