From 0aa9db4fd5160936842943b3709f1ab40d91b4c9 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 1 Dec 2023 17:16:12 +0800 Subject: [PATCH] valid msg --- include/common/tmsg.h | 14 ++++++++++++-- include/common/tmsgdef.h | 5 +++++ source/common/src/tmsg.c | 11 ----------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index be5b51d938..b42df78e34 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -55,6 +55,7 @@ extern "C" { extern char* tMsgInfo[]; extern int32_t tMsgDict[]; +extern int32_t tMsgRangeDict[]; typedef uint16_t tmsg_t; @@ -62,8 +63,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 3b229e4c1d..61b471912f 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -364,6 +364,11 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) 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 diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c7e67c81f5..d69542c98b 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -39,17 +39,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 { \ if (!tDecodeIsEnd(&decoder)) { \