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

Function cont_check_cacheable

plugins/experimental/cache_fill/cache_fill.cc:72–107  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////// create background fetch request if possible

Source from the content-addressed store, hash-verified

70// create background fetch request if possible
71//
72static bool
73cont_check_cacheable(TSHttpTxn txnp)
74{
75 if (TSHttpTxnIsInternal(txnp)) {
76 return false;
77 }
78 int lookupStatus;
79 if (TSHttpTxnCacheLookupStatusGet(txnp, &lookupStatus) == TS_ERROR) {
80 TSError("[%s] Couldn't get cache status of object", PLUGIN_NAME);
81 return false;
82 }
83 Dbg(dbg_ctl, "lookup status: %s", getCacheLookupResultName(static_cast<TSCacheLookupResult>(lookupStatus)));
84 bool ret = false;
85 if (TS_CACHE_LOOKUP_MISS == lookupStatus || TS_CACHE_LOOKUP_HIT_STALE == lookupStatus) {
86 bool const nostore = TSHttpTxnServerRespNoStoreGet(txnp);
87
88 Dbg(dbg_ctl, "is nostore set %d", nostore);
89 if (!nostore) {
90 TSMBuffer request;
91 TSMLoc req_hdr;
92 if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &request, &req_hdr)) {
93 BgFetchData *data = new BgFetchData();
94 // Initialize the data structure (can fail) and acquire a privileged lock on the URL
95 if (data->initialize(request, req_hdr, txnp) && data->acquireUrl()) {
96 Dbg(dbg_ctl, "scheduling background fetch");
97 data->schedule();
98 ret = true;
99 } else {
100 delete data;
101 }
102 }
103 TSHandleMLocRelease(request, TS_NULL_MLOC, req_hdr);
104 }
105 }
106 return ret;
107}
108
109//////////////////////////////////////////////////////////////////////////////
110// Main "plugin", which is a global TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE hook. Before

Callers 1

cont_handle_cacheFunction · 0.70

Calls 10

TSHttpTxnIsInternalFunction · 0.85
TSHttpTxnClientReqGetFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
getCacheLookupResultNameFunction · 0.70
TSErrorFunction · 0.50
initializeMethod · 0.45
acquireUrlMethod · 0.45
scheduleMethod · 0.45

Tested by

no test coverage detected