--------------------- PatchSet 446 Date: 2002/12/20 22:36:54 Author: rbcollins Branch: esi Tag: (none) Log: prepare caching for sequences, literals and comments Members: src/ESI.cc:1.1.2.59->1.1.2.60 src/ESIElement.h:1.1.2.6->1.1.2.7 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.59 retrieving revision 1.1.2.60 diff -u -r1.1.2.59 -r1.1.2.60 --- squid3/src/ESI.cc 20 Dec 2002 21:24:46 -0000 1.1.2.59 +++ squid3/src/ESI.cc 20 Dec 2002 22:36:54 -0000 1.1.2.60 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.59 2002/12/20 21:24:46 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.60 2002/12/20 22:36:54 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -192,6 +192,7 @@ void deleteSelf()const; ~esiComment(); esiComment(); + Pointer makeCacheable() const; void render(ESISegment *); private: @@ -211,6 +212,7 @@ void render(ESISegment *); esiProcessResult_t process (int dovars); + Pointer makeCacheable() const; /* optimise copies away later */ ESISegment *buffer; struct { @@ -219,6 +221,7 @@ esiVarState *varState; private: static MemPool *pool; + esiLiteral(esiLiteral const &); }; MemPool *esiLiteral::pool = NULL; @@ -239,6 +242,7 @@ bool mayFail () const; void wontFail(); void fail(ESIElement *); + Pointer makeCacheable() const; ESIElement::Pointer * elements; /* unprocessed or rendered nodes */ int allocedcount; @@ -256,6 +260,7 @@ bool failed; esiProcessResult_t processOne(int, int); bool const provideIncrementalData; + esiSequence(esiSequence const &); }; MemPool *esiSequence::Pool = NULL; @@ -269,6 +274,7 @@ ~esiInclude(); void render(ESISegment *); esiProcessResult_t process (int dovars); + Pointer makeCacheable() const; void subRequestDone (esiStreamContext *, bool); struct { int onerrorcontinue:1; /* on error return zero data */ @@ -302,6 +308,7 @@ esiRemove(); void render(ESISegment *); bool addElement (ESIElement::Pointer); + Pointer makeCacheable() const; }; CBDATA_TYPE (esiRemove); static FREE esiRemoveFree; @@ -337,6 +344,7 @@ void fail(ESIElement *); esiProcessResult_t process (int dovars); void provideData (ESISegment *data, ESIElement * source); + Pointer makeCacheable() const; ESIElement::Pointer attempt; ESIElement::Pointer except; @@ -379,6 +387,7 @@ esiProcessResult_t process (int dovars); void provideData (ESISegment *data, ESIElement *source); + Pointer makeCacheable() const; ESIElement::Pointer * elements; /* unprocessed nodes */ int allocedcount; @@ -400,6 +409,7 @@ void operator delete (void *address); void deleteSelf() const; esiWhen(esiTreeParentPtr aParent, int attributes, const char **attr, esiVarState *); + Pointer makeCacheable() const; bool testsTrue() const { return testValue;} void setTestResult(bool aBool) {testValue = aBool;} @@ -1481,6 +1491,9 @@ return ESI_PROCESS_PENDING_MAYFAIL; } + ESIElement::Pointer treeToCache = tree->makeCacheable(); + treeToCache = NULL; + /* ok, we've done all we can with the data. What can we process now? */ { @@ -1800,6 +1813,13 @@ debug (86, 5)("esiCommentRender: Rendering comment %p\n", output); } +ESIElement::Pointer +esiComment::makeCacheable() const +{ + debug (86, 5) ("esiComment::makeCacheable: returning NULL\n"); + return NULL; +} + /* esiLiteral */ void * esiLiteral::operator new(size_t byteCount) @@ -1890,6 +1910,18 @@ return ESI_PROCESS_COMPLETE; } +esiLiteral::esiLiteral(esiLiteral const &old) : buffer (old.buffer->clone()), +varState (NULL) +{ + flags.donevars = 0; +} + +ESIElement::Pointer +esiLiteral::makeCacheable() const +{ + return new esiLiteral (*this); +} + /* esiSequence */ void esiSequence::deleteSelf() const @@ -2094,6 +2126,27 @@ { parent->fail (this); } + +esiSequence::esiSequence(esiSequence const &old) + : processedcount (0), mayFail_(old.mayFail_), failed (old.failed), provideIncrementalData (old.provideIncrementalData) +{ + flags.dovars = old.flags.dovars; + parent = NULL; + + for (int counter = 0; counter < old.elementcount; ++counter) + assert (addElement(old.elements[counter]->makeCacheable())); +} + +ESIElement::Pointer +esiSequence::makeCacheable() const +{ + assert (processedcount == 0); + assert (!failed); + if (elementcount == 0) + return NULL; + ESIElement::Pointer result = new esiSequence (*this); + return result; +} /* esiInclude */ esiInclude::~esiInclude() @@ -2127,6 +2180,13 @@ delete this; } +ESIElement::Pointer +esiInclude::makeCacheable() const +{ + fatal ("esiInclude not implemented\n"); + return NULL; +} + void esiIncludeStart (esiStreamContext *, char const *, esiVarState *); @@ -2403,6 +2463,13 @@ return true; } +ESIElement::Pointer +esiRemove::makeCacheable() const +{ + fatal ("esiRemove not implemented\n"); + return NULL; +} + /* esiTry */ esiTry::~esiTry() { @@ -2590,6 +2657,12 @@ } } +ESIElement::Pointer +esiTry::makeCacheable() const +{ + fatal ("esiTry not implemented\n"); + return NULL; +} /* esiAttempt */ #if 0 @@ -3344,6 +3417,13 @@ parent->provideData (data, this); } +ESIElement::Pointer +esiChoose::makeCacheable() const +{ + fatal ("esiChoose not implemented\n"); + return NULL; +} + /* esiWhen */ void * esiWhen::operator new(size_t byteCount) @@ -3394,6 +3474,13 @@ safe_free (expression); } +ESIElement::Pointer +esiWhen::makeCacheable() const +{ + fatal ("esiWhen not implemented\n"); + return NULL; +} + /* esiOtherwise */ #if 0 void * Index: squid3/src/ESIElement.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESIElement.h,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid3/src/ESIElement.h 20 Dec 2002 07:12:53 -0000 1.1.2.6 +++ squid3/src/ESIElement.h 20 Dec 2002 22:36:54 -0000 1.1.2.7 @@ -1,5 +1,5 @@ /* - * $Id: ESIElement.h,v 1.1.2.6 2002/12/20 07:12:53 rbcollins Exp $ + * $Id: ESIElement.h,v 1.1.2.7 2002/12/20 22:36:54 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -74,6 +74,8 @@ virtual bool mayFail() const { return true; } + + virtual Pointer makeCacheable() const = 0; }; #endif /* SQUID_ESIELEMENT_H */