diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index fb8ab48498fa48e38df5cbc1fda342ef8fcde130..106ba9a772aaaaf4918b7915dd79c2114d7ca877 100644 --- a/src/plugins/http/src/httpContext.c +++ b/src/plugins/http/src/httpContext.c @@ -67,7 +67,7 @@ static void httpDestroyContext(void *data) { } bool httpInitContexts() { - tsHttpServer.contextCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 2, true, httpDestroyContext, "restc"); + tsHttpServer.contextCache = taosCacheInit(TSDB_CACHE_PTR_KEY, 2, true, httpDestroyContext, "restc"); if (tsHttpServer.contextCache == NULL) { httpError("failed to init context cache"); return false; @@ -117,8 +117,8 @@ HttpContext *httpCreateContext(int32_t fd) { pContext->state = HTTP_CONTEXT_STATE_READY; pContext->parser = httpCreateParser(pContext); - uint64_t handleVal = (uint64_t)pContext; - HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(int64_t), &pContext, sizeof(int64_t), 3000); + TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pContext; + HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, TSDB_CACHE_PTR_LEN, &pContext, TSDB_CACHE_PTR_LEN, 3000); pContext->ppContext = ppContext; httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, ppContext); @@ -129,8 +129,8 @@ HttpContext *httpCreateContext(int32_t fd) { } HttpContext *httpGetContext(void *ptr) { - uint64_t handleVal = (uint64_t)ptr; - HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(uint64_t)); + TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)ptr; + HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, TSDB_CACHE_PTR_LEN); if (ppContext) { HttpContext *pContext = *ppContext; diff --git a/src/util/inc/tcache.h b/src/util/inc/tcache.h index af5f30c7c3858ee37af253589cdd5e4323ad1d69..6ef02b63d704ec60171351bad62e402aba5e1909 100644 --- a/src/util/inc/tcache.h +++ b/src/util/inc/tcache.h @@ -24,6 +24,16 @@ extern "C" { #include "tlockfree.h" #include "hash.h" +#if defined(_TD_ARM_32) + #define TSDB_CACHE_PTR_KEY TSDB_DATA_TYPE_INT + #define TSDB_CACHE_PTR_TYPE int32_t + #define TSDB_CACHE_PTR_LEN sizeof(int32_t) +#else + #define TSDB_CACHE_PTR_KEY TSDB_DATA_TYPE_BIGINT + #define TSDB_CACHE_PTR_TYPE int64_t + #define TSDB_CACHE_PTR_LEN sizeof(int64_t) +#endif + typedef void (*__cache_free_fn_t)(void*); typedef struct SCacheStatis {