Context.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 86 ESI processing */
10 
11 #include "squid.h"
12 
13 /* MS Visual Studio Projects are monolithic, so we need the following
14  * #if to exclude the ESI code from compile process when not needed.
15  */
16 #if (USE_SQUID_ESI == 1)
17 
18 #include "client_side_request.h"
19 #include "esi/Context.h"
20 #include "http/Stream.h"
21 #include "Store.h"
22 
23 void
25 {
26  assert (http);
27  assert (http->storeEntry());
28 
29  if (hasCachedAST()) {
30  debugs(86, 5, "ESIContext::updateCachedAST: not updating AST cache for entry " <<
31  http->storeEntry() << " from ESI Context " << this <<
32  " as there is already a cached AST.");
33 
34  return;
35  }
36 
37  ESIElement::Pointer treeToCache = tree->makeCacheable();
38  debugs(86, 5, "ESIContext::updateCachedAST: Updating AST cache for entry " <<
39  http->storeEntry() << " with current value " <<
40  http->storeEntry()->cachedESITree.getRaw() << " to new value " <<
41  treeToCache.getRaw());
42 
45 
46  http->storeEntry()->cachedESITree = treeToCache;
47 
48  treeToCache = NULL;
49 }
50 
51 bool
53 {
54  assert (http);
55  assert (http->storeEntry());
56 
57  if (http->storeEntry()->cachedESITree.getRaw()) {
58  debugs(86, 5, "ESIContext::hasCachedAST: " << this <<
59  " - Cached AST present in store entry " << http->storeEntry() << ".");
60  return true;
61  } else {
62  debugs(86, 5, "ESIContext::hasCachedAST: " << this <<
63  " - Cached AST not present in store entry " << http->storeEntry() << ".");
64  return false;
65  }
66 }
67 
68 void
70 {
71  if (cachedASTInUse)
72  return;
73 
74  assert (hasCachedAST());
75 
76  assert (varState);
77 
79 
81 
82  cachedASTInUse = true;
83 }
84 
85 void
86 ESIContext::setErrorMessage(char const *anError)
87 {
88  if (!errormessage)
89  errormessage = xstrdup(anError);
90 }
91 
92 #endif /* USE_SQUID_ESI == 1 */
93 
virtual Pointer makeUsable(esiTreeParentPtr, ESIVarState &) const =0
#define assert(EX)
Definition: assert.h:17
ESIElement::Pointer tree
Definition: Context.h:133
#define xstrdup
virtual Pointer makeCacheable() const =0
ESIElement::Pointer cachedESITree
Definition: Store.h:204
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
void updateCachedAST()
Definition: Context.cc:24
virtual void finish()=0
void setErrorMessage(char const *)
Definition: Context.cc:86
char * errormessage
Definition: Context.h:95
StoreEntry * storeEntry() const
bool hasCachedAST() const
Definition: Context.cc:52
bool cachedASTInUse
Definition: Context.h:139
ClientHttpRequest * http
Definition: Context.h:74
void getCachedAST()
Definition: Context.cc:69
ESIVarState * varState
Definition: Context.h:132
class ESIContext::ParserState parserState
C * getRaw() const
Definition: RefCount.h:74
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors