MCPcopy Create free account
hub / github.com/apache/trafficserver / cont_handle_cache

Function cont_handle_cache

plugins/experimental/cache_fill/cache_fill.cc:114–141  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////// Main "plugin", which is a global TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE hook. Before initiating a background fetch, this checks if a background fetch is allowed for this request

Source from the content-addressed store, hash-verified

112// if a background fetch is allowed for this request
113//
114static int
115cont_handle_cache(TSCont contp, TSEvent event, void *edata)
116{
117 TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
118 BgFetchConfig *config = static_cast<BgFetchConfig *>(TSContDataGet(contp));
119
120 if (nullptr == config) {
121 // something seriously wrong..
122 TSError("[%s] Can't get configurations", PLUGIN_NAME);
123 } else if (config->bgFetchAllowed(txnp)) {
124 if (TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE == event) {
125 bool const requested = cont_check_cacheable(txnp);
126 if (requested) // Made a background fetch request, do not cache the response
127 {
128 Dbg(dbg_ctl, "setting no store");
129 TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SERVER_NO_STORE, true);
130 TSHttpTxnCacheLookupStatusSet(txnp, TS_CACHE_LOOKUP_MISS);
131 }
132
133 } else {
134 TSError("[%s] Unknown event for this plugin %d", PLUGIN_NAME, event);
135 Dbg(dbg_ctl, "unknown event for this plugin %d", event);
136 }
137 }
138 // Reenable and continue with the state machine.
139 TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
140 return 0;
141}
142
143///////////////////////////////////////////////////////////////////////////
144// Setup global hooks

Callers

nothing calls this directly

Calls 7

TSContDataGetFunction · 0.85
TSHttpTxnCntlSetFunction · 0.85
TSHttpTxnReenableFunction · 0.85
cont_check_cacheableFunction · 0.70
TSErrorFunction · 0.50
bgFetchAllowedMethod · 0.45

Tested by

no test coverage detected