TD-1530
This commit is contained in:
parent
3b724adeb3
commit
dec6288006
|
@ -67,7 +67,7 @@ static void httpDestroyContext(void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool httpInitContexts() {
|
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) {
|
if (tsHttpServer.contextCache == NULL) {
|
||||||
httpError("failed to init context cache");
|
httpError("failed to init context cache");
|
||||||
return false;
|
return false;
|
||||||
|
@ -117,8 +117,8 @@ HttpContext *httpCreateContext(int32_t fd) {
|
||||||
pContext->state = HTTP_CONTEXT_STATE_READY;
|
pContext->state = HTTP_CONTEXT_STATE_READY;
|
||||||
pContext->parser = httpCreateParser(pContext);
|
pContext->parser = httpCreateParser(pContext);
|
||||||
|
|
||||||
uint64_t handleVal = (uint64_t)pContext;
|
TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pContext;
|
||||||
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(int64_t), &pContext, sizeof(int64_t), 3000);
|
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, TSDB_CACHE_PTR_LEN, &pContext, TSDB_CACHE_PTR_LEN, 3000);
|
||||||
pContext->ppContext = ppContext;
|
pContext->ppContext = ppContext;
|
||||||
httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, 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) {
|
HttpContext *httpGetContext(void *ptr) {
|
||||||
uint64_t handleVal = (uint64_t)ptr;
|
TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)ptr;
|
||||||
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(uint64_t));
|
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, TSDB_CACHE_PTR_LEN);
|
||||||
|
|
||||||
if (ppContext) {
|
if (ppContext) {
|
||||||
HttpContext *pContext = *ppContext;
|
HttpContext *pContext = *ppContext;
|
||||||
|
|
|
@ -24,6 +24,16 @@ extern "C" {
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "hash.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 void (*__cache_free_fn_t)(void*);
|
||||||
|
|
||||||
typedef struct SCacheStatis {
|
typedef struct SCacheStatis {
|
||||||
|
|
Loading…
Reference in New Issue