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

Function TSHttpTxnCacheLookupStatusSet

src/api/InkAPI.cc:4202–4237  ·  view source on GitHub ↗

two hooks this function may gets called: TS_HTTP_READ_CACHE_HDR_HOOK & TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK */

Source from the content-addressed store, hash-verified

4200 TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK
4201 */
4202TSReturnCode
4203TSHttpTxnCacheLookupStatusSet(TSHttpTxn txnp, int cachelookup)
4204{
4205 sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
4206
4207 HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
4208 HttpTransact::CacheLookupResult_t *sm_status = &(sm->t_state.cache_lookup_result);
4209
4210 // converting from a miss to a hit is not allowed
4211 if (*sm_status == HttpTransact::CACHE_LOOKUP_MISS && cachelookup != TS_CACHE_LOOKUP_MISS) {
4212 return TS_ERROR;
4213 }
4214
4215 // here is to handle converting a hit to a miss
4216 if (cachelookup == TS_CACHE_LOOKUP_MISS && *sm_status != HttpTransact::CACHE_LOOKUP_MISS) {
4217 sm->t_state.api_cleanup_cache_read = true;
4218 ink_assert(sm->t_state.transact_return_point != nullptr);
4219 sm->t_state.transact_return_point = HttpTransact::HandleCacheOpenRead;
4220 }
4221
4222 switch (cachelookup) {
4223 case TS_CACHE_LOOKUP_MISS:
4224 *sm_status = HttpTransact::CACHE_LOOKUP_MISS;
4225 break;
4226 case TS_CACHE_LOOKUP_HIT_STALE:
4227 *sm_status = HttpTransact::CACHE_LOOKUP_HIT_STALE;
4228 break;
4229 case TS_CACHE_LOOKUP_HIT_FRESH:
4230 *sm_status = HttpTransact::CACHE_LOOKUP_HIT_FRESH;
4231 break;
4232 default:
4233 return TS_ERROR;
4234 }
4235
4236 return TS_SUCCESS;
4237}
4238
4239TSReturnCode
4240TSHttpTxnInfoIntGet(TSHttpTxn txnp, TSHttpTxnInfoKey key, TSMgmtInt *value)

Callers 6

main_handlerFunction · 0.85
cont_handle_cacheFunction · 0.85
send_stale_responseFunction · 0.85
transaction_handlerFunction · 0.85

Calls 1

sdk_sanity_check_txnFunction · 0.85

Tested by

no test coverage detected