From dec6288006b3cc66124d09f8f09b579f22112062 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 28 Sep 2020 07:59:35 +0000 Subject: [PATCH] TD-1530 --- src/plugins/http/src/httpContext.c | 10 +++++----- src/util/inc/tcache.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index fb8ab48498..106ba9a772 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 af5f30c7c3..6ef02b63d7 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 { -- GitLab