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

Function TSHttpTxnCachedReqGet

src/api/InkAPI.cc:4044–4080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4042}
4043
4044TSReturnCode
4045TSHttpTxnCachedReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
4046{
4047 sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
4048 sdk_assert(sdk_sanity_check_null_ptr((void *)bufp) == TS_SUCCESS);
4049 sdk_assert(sdk_sanity_check_null_ptr((void *)obj) == TS_SUCCESS);
4050
4051 HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
4052 HTTPInfo *cached_obj = sm->t_state.cache_info.object_read;
4053
4054 // The following check is need to prevent the HttpSM handle copy from going bad
4055 // Since the cache manages the header buffer, sm->t_state.cache_info.object_read
4056 // is the only way to tell if handle has gone bad.
4057 if ((!cached_obj) || (!cached_obj->valid())) {
4058 return TS_ERROR;
4059 }
4060
4061 HTTPHdr *cached_hdr = sm->t_state.cache_info.object_read->request_get();
4062
4063 if (!cached_hdr->valid()) {
4064 return TS_ERROR;
4065 }
4066 // We can't use the HdrHeapSDKHandle structure in the RamCache since multiple
4067 // threads can access. We need to create our own for the transaction and return that.
4068 HdrHeapSDKHandle **handle = &(sm->t_state.cache_req_hdr_heap_handle);
4069
4070 if (*handle == nullptr) {
4071 *handle = static_cast<HdrHeapSDKHandle *>(sm->t_state.arena.alloc(sizeof(HdrHeapSDKHandle)));
4072 (*handle)->m_heap = cached_hdr->m_heap;
4073 }
4074
4075 *(reinterpret_cast<HdrHeapSDKHandle **>(bufp)) = *handle;
4076 *obj = reinterpret_cast<TSMLoc>(cached_hdr->m_http);
4077 sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
4078
4079 return TS_SUCCESS;
4080}
4081
4082TSReturnCode
4083TSHttpTxnCachedRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)

Callers 1

cache_hook_handlerFunction · 0.85

Calls 6

sdk_sanity_check_txnFunction · 0.85
sdk_sanity_check_mbufferFunction · 0.85
request_getMethod · 0.80
validMethod · 0.45
allocMethod · 0.45

Tested by 1

cache_hook_handlerFunction · 0.68