From cf16ebfe72b020110eb218cd09863521ad305ee1 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 5 Jun 2023 10:40:03 +0800 Subject: [PATCH] chore: code optimization --- include/common/tgrant.h | 4 ++++ source/dnode/vnode/src/sma/smaTimeRange.c | 2 +- source/dnode/vnode/src/vnd/vnodeSvr.c | 2 -- source/libs/qworker/src/qwMsg.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/common/tgrant.h b/include/common/tgrant.h index 46e09a56b6..d46a74073b 100644 --- a/include/common/tgrant.h +++ b/include/common/tgrant.h @@ -48,6 +48,10 @@ typedef enum { TSDB_GRANT_TABLE, } EGrantType; +static int8_t tsGrant = 1; + +static FORCE_INLINE int8_t taosGranted() { return atomic_load_8(&tsGrant); } + int32_t grantCheck(EGrantType grant); #ifndef GRANTS_CFG diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 3542ea9ffb..6a6007cae4 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -355,7 +355,7 @@ _end: */ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { const SArray *pDataBlocks = (const SArray *)msg; - // TODO: destroy SSDataBlocks(msg) + if (!pDataBlocks) { terrno = TSDB_CODE_TSMA_INVALID_PTR; smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma)); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index b950437f23..12a55049c3 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -588,9 +588,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { } } -// TODO: remove the function void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { - // TODO // blockDebugShowDataBlocks(data, __func__); tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); } diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index 231e597724..508e957e26 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -366,7 +366,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg, bool chkGran QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && (grantCheck(TSDB_GRANT_TIME) != TSDB_CODE_SUCCESS)) { + if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && !taosGranted()) { QW_ELOG("query failed cause of grant expired, msgMask:%d", msg.msgMask); tFreeSSubQueryMsg(&msg); QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED); -- GitLab