Skip to content

Commit

Permalink
Revert "First cut at header heap genIDs and new API (#11780)" (#11853)
Browse files Browse the repository at this point in the history
This reverts commit 8ecad69.

Cache compatibility issues.
  • Loading branch information
zwoop authored Nov 15, 2024
1 parent f6c051b commit 5e72ad5
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 59 deletions.
4 changes: 1 addition & 3 deletions include/proxy/hdrs/HdrHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ class HdrHeap
char *m_free_start;
char *m_data_start;
uint32_t m_size;
uint32_t m_genid;

bool m_writeable;

Expand Down Expand Up @@ -485,8 +484,7 @@ struct HdrHeapSDKHandle {
void set(const HdrHeapSDKHandle *from);
const char *make_sdk_string(const char *raw_str, int raw_str_len);

HdrHeap *m_heap = nullptr;
uint32_t m_genid = 0;
HdrHeap *m_heap = nullptr;

// In order to prevent gratitous refcounting,
// automatic C++ copies are disabled!
Expand Down
6 changes: 0 additions & 6 deletions include/ts/ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,6 @@ TSMBuffer TSMBufferCreate(void);
*/
TSReturnCode TSMBufferDestroy(TSMBuffer bufp);

/**
Check to see if an MBuffer is still valid, from since the time
it was acquired.
*/
bool TSMBufferIsValid(TSMBuffer bufp);

/* --------------------------------------------------------------------------
URLs */
/**
Expand Down
48 changes: 1 addition & 47 deletions src/api/InkAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -407,28 +407,9 @@ sdk_sanity_check_mbuffer(TSMBuffer bufp)
return TS_ERROR;
}

// ToDo: Can we safely check here that TSMbufferIsValid() is true?

return TS_SUCCESS;
}

// This will reset the TSMBuffer's genid to the current genid of the heap. Any TS API
// that returns a TSMBuffer should call this function before returning the buffer to the user.
// The user (plugin) is responsible for calling TSMBufferIsValid() before using any previous
// values returned by the TS API for the TSMBuffer.
inline void
sdk_revalidate_mbuffer(TSMBuffer bufp)
{
HdrHeapSDKHandle *sdk_heap = (HdrHeapSDKHandle *)bufp;

// Lets not segfault in here, even though the bufp should have been validated before calling this function.
if (unlikely(bufp == nullptr || sdk_heap->m_heap == nullptr)) {
return;
}

sdk_heap->m_genid = sdk_heap->m_heap->m_genid;
}

TSReturnCode
sdk_sanity_check_mime_hdr_handle(TSMLoc field)
{
Expand Down Expand Up @@ -919,15 +900,6 @@ TSMBufferDestroy(TSMBuffer bufp)
return TS_SUCCESS;
}

bool
TSMBufferIsValid(TSMBuffer bufp)
{
sdk_assert(sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS);
HdrHeapSDKHandle *sdk_heap = (HdrHeapSDKHandle *)bufp;

return (sdk_heap->m_heap->m_genid == sdk_heap->m_genid);
}

////////////////////////////////////////////////////////////////////
//
// URLs
Expand Down Expand Up @@ -3128,7 +3100,6 @@ TSCacheHttpInfoReqGet(TSCacheHttpInfo infop, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HTTPHdr **>(bufp)) = info->request_get();
*obj = reinterpret_cast<TSMLoc>(info->request_get()->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);
}

void
Expand All @@ -3139,7 +3110,6 @@ TSCacheHttpInfoRespGet(TSCacheHttpInfo infop, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HTTPHdr **>(bufp)) = info->response_get();
*obj = reinterpret_cast<TSMLoc>(info->response_get()->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);
}

time_t
Expand Down Expand Up @@ -3912,9 +3882,8 @@ TSHttpTxnClientReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
if (sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS) {
hptr->mark_target_dirty();
sdk_revalidate_mbuffer(*bufp);

return TS_SUCCESS;
;
}
}
return TS_ERROR;
Expand All @@ -3936,7 +3905,6 @@ TSHttpTxnPristineUrlGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *url_loc)
*url_loc = (TSMLoc)sm->t_state.unmapped_url.m_url_impl;

if (sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS) {
sdk_revalidate_mbuffer(*bufp);
if (*url_loc == nullptr) {
*url_loc = (TSMLoc)hptr->m_http->u.req.m_url_impl;
}
Expand Down Expand Up @@ -4022,8 +3990,6 @@ TSHttpTxnClientRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HTTPHdr **>(bufp)) = hptr;
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);

return TS_SUCCESS;
}

Expand All @@ -4044,8 +4010,6 @@ TSHttpTxnServerReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HTTPHdr **>(bufp)) = hptr;
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);

return TS_SUCCESS;
}

Expand All @@ -4066,8 +4030,6 @@ TSHttpTxnServerRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HTTPHdr **>(bufp)) = hptr;
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);

return TS_SUCCESS;
}

Expand Down Expand Up @@ -4108,7 +4070,6 @@ TSHttpTxnCachedReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HdrHeapSDKHandle **>(bufp)) = *handle;
*obj = reinterpret_cast<TSMLoc>(cached_hdr->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);

return TS_SUCCESS;
}
Expand Down Expand Up @@ -4148,7 +4109,6 @@ TSHttpTxnCachedRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HdrHeapSDKHandle **>(bufp)) = *handle;
*obj = reinterpret_cast<TSMLoc>(cached_hdr->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);

return TS_SUCCESS;
}
Expand Down Expand Up @@ -4185,7 +4145,6 @@ TSHttpTxnCachedRespModifiableGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HTTPHdr **>(bufp)) = c_resp;
*obj = reinterpret_cast<TSMLoc>(c_resp->m_http);
sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS);
sdk_revalidate_mbuffer(*bufp);

return TS_SUCCESS;
}
Expand Down Expand Up @@ -4618,7 +4577,6 @@ TSHttpTxnTransformRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
if (hptr->valid()) {
*(reinterpret_cast<HTTPHdr **>(bufp)) = hptr;
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
sdk_revalidate_mbuffer(*bufp);
return sdk_sanity_check_mbuffer(*bufp);
}

Expand Down Expand Up @@ -5552,7 +5510,6 @@ TSHttpAltInfoClientReqGet(TSHttpAltInfo infop, TSMBuffer *bufp, TSMLoc *obj)

*(reinterpret_cast<HTTPHdr **>(bufp)) = &info->m_client_req;
*obj = reinterpret_cast<TSMLoc>(info->m_client_req.m_http);
sdk_revalidate_mbuffer(*bufp);

return sdk_sanity_check_mbuffer(*bufp);
}
Expand All @@ -5566,7 +5523,6 @@ TSHttpAltInfoCachedReqGet(TSHttpAltInfo infop, TSMBuffer *bufp, TSMLoc *obj)

*(reinterpret_cast<HTTPHdr **>(bufp)) = &info->m_cached_req;
*obj = reinterpret_cast<TSMLoc>(info->m_cached_req.m_http);
sdk_revalidate_mbuffer(*bufp);

return sdk_sanity_check_mbuffer(*bufp);
}
Expand All @@ -5580,7 +5536,6 @@ TSHttpAltInfoCachedRespGet(TSHttpAltInfo infop, TSMBuffer *bufp, TSMLoc *obj)

*(reinterpret_cast<HTTPHdr **>(bufp)) = &info->m_cached_resp;
*obj = reinterpret_cast<TSMLoc>(info->m_cached_resp.m_http);
sdk_revalidate_mbuffer(*bufp);

return sdk_sanity_check_mbuffer(*bufp);
}
Expand Down Expand Up @@ -6626,7 +6581,6 @@ TSFetchPageRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
if (hptr->valid()) {
*(reinterpret_cast<HTTPHdr **>(bufp)) = hptr;
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
sdk_revalidate_mbuffer(*bufp);
return sdk_sanity_check_mbuffer(*bufp);
}

Expand Down
3 changes: 0 additions & 3 deletions src/proxy/hdrs/HdrHeap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ HdrHeap::init()
{
m_data_start = m_free_start = (reinterpret_cast<char *>(this)) + HDR_HEAP_HDR_SIZE;
m_magic = HDR_BUF_MAGIC_ALIVE;
m_genid = 0;
m_writeable = true;

m_next = nullptr;
Expand Down Expand Up @@ -371,8 +370,6 @@ HdrHeap::coalesce_str_heaps(int incoming_size)
ink_assert(incoming_size >= 0);
ink_assert(m_writeable);

++m_genid;

new_heap_size += required_space_for_evacuation();

HdrStrHeap *new_heap = HdrStrHeap::alloc(new_heap_size);
Expand Down

0 comments on commit 5e72ad5

Please sign in to comment.