From c5d9a2b24d58fe64ab1747943a34c0414354eaf9 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 1 Dec 2023 17:19:34 +0800 Subject: [PATCH] add valid msg --- include/common/tmsg.h | 14 ++++++++++++-- include/common/tmsgdef.h | 2 ++ source/common/src/tmsg.c | 11 ----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f406631975..b4a88bd55a 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -56,6 +56,7 @@ extern "C" { extern char* tMsgInfo[]; extern int32_t tMsgDict[]; +extern int32_t tMsgRangeDict[]; typedef uint16_t tmsg_t; @@ -63,8 +64,17 @@ typedef uint16_t tmsg_t; #define TMSG_SEG_SEQ(TYPE) ((TYPE)&0xff) #define TMSG_INDEX(TYPE) (tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)) -bool tmsgIsValid(tmsg_t type); -char* TMSG_INFO(tmsg_t type); +static inline bool tmsgIsValid(tmsg_t type) { + // static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]); + int8_t maxSegIdx = TMSG_SEG_CODE(TDMT_MAX_MSG); + int segIdx = TMSG_SEG_CODE(type); + if (segIdx >= 0 && segIdx < maxSegIdx) { + return type < tMsgRangeDict[segIdx]; + } + return false; +} + +#define TMSG_INFO(type) (tmsgIsValid(type) ? tMsgInfo[TMSG_INDEX(type)] : "unKnown") static inline bool vnodeIsMsgBlock(tmsg_t type) { return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) || diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 0467083d4c..afd7034319 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -362,6 +362,8 @@ enum { // WARN: new msg should be appended to segment tail TD_DEF_MSG_TYPE(TDMT_VND_TMQ_MAX_MSG, "vnd-tmq-max", NULL, NULL) TD_CLOSE_MSG_TYPE(TDMT_END_TMQ_MSG) + TD_NEW_MSG_SEG(TDMT_MAX_MSG) // msg end mark + #if defined(TD_MSG_NUMBER_) TDMT_MAX #endif diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 763a9e6280..4e828812f1 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -37,17 +37,6 @@ #include "tlog.h" -inline bool tmsgIsValid(tmsg_t type) { - static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]); - - int segIdx = TMSG_SEG_CODE(type); - if (segIdx >= 0 && segIdx < sz) { - return type < tMsgRangeDict[segIdx]; - } - return false; -} - -inline char *TMSG_INFO(tmsg_t type) { return (tmsgIsValid(type) ? tMsgInfo[TMSG_INDEX(type)] : "unKnown"); }; #define DECODESQL() \ do { \