From d9b73f35a9fb496aed1135cb488aead05b313667 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 22 Dec 2021 11:33:41 +0800 Subject: [PATCH] code optimization --- src/common/inc/tglobal.h | 3 ++- src/common/src/tglobal.c | 2 -- src/dnode/src/dnodeVWrite.c | 2 +- src/rpc/src/rpcMain.c | 4 ++-- src/vnode/src/vnodeWrite.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 1fa062f609..81c6f8bd44 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -247,7 +247,8 @@ bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t void taosAddDataDir(int index, char *v1, int level, int primary); void taosReadDataDirCfg(char *v1, char *v2, char *v3); void taosPrintDataDirCfg(); -bool taosPrintCreateTable(); + +#define TAOS_PRINT_CREATE_TABLE (tsSpecificLogType & LOG_CREATE_TABLE) #ifdef __cplusplus } diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 7f8b682909..d5b51ddcc6 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -1831,5 +1831,3 @@ bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *d return true; } - -bool taosPrintCreateTable() { return (tsSpecificLogType & LOG_CREATE_TABLE) ? true : false; } diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index a247640105..21d36c0747 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -203,7 +203,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) { bool forceFsync = false; for (int32_t i = 0; i < numOfMsgs; ++i) { taosGetQitem(pWorker->qall, &qtype, (void **)&pWrite); - if ((pWrite->walHead.msgType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && taosPrintCreateTable()) { + if ((pWrite->walHead.msgType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && TAOS_PRINT_CREATE_TABLE) { SMDCreateTableMsg *pMsg = (SMDCreateTableMsg *)pWrite->walHead.cont; dInfo("msg:%p, app:%p type:%s for uid:%" PRIu64 ", tid:%" PRIu32 " will be processed in vwrite queue, qtype:%s hver:%" PRIu64, diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index b4a5fe4daf..69f5263c8d 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1161,7 +1161,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqConte rpcAddRef(pRpc); // add the refCount for requests // notify the server app - if ((rpcMsg.msgType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && taosPrintCreateTable()) { + if ((rpcMsg.msgType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && TAOS_PRINT_CREATE_TABLE) { SMDCreateTableMsg *pMsg = (SMDCreateTableMsg *)rpcMsg.pCont; tInfo("%p, msg:%s received, uid:%" PRIu64 ", tid:%" PRIu32, rpcMsg.ahandle, taosMsg[rpcMsg.msgType], htobe64(pMsg->uid), htonl(pMsg->tid)); @@ -1353,7 +1353,7 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) { } //tTrace("connection type is: %d", pConn->connType); - if ((pConn->outType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && taosPrintCreateTable()) { + if ((pConn->outType == TSDB_MSG_TYPE_MD_CREATE_TABLE) && TAOS_PRINT_CREATE_TABLE) { tInfo("%s, msg:%s is sent to 0x%x:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", pConn->info, taosMsg[pHead->msgType], pConn->peerIp, pConn->peerPort, htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId); } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 35385de929..64460d9aee 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -191,7 +191,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe ASSERT(code != 0); } - if (taosPrintCreateTable()) { + if (TAOS_PRINT_CREATE_TABLE) { vInfo("vgId:%d, table[%s], uid:%" PRIu64 ", tid:%" PRIu32 " is created successfully", pVnode->vgId, pMsg->tableFname, htobe64(pMsg->uid), htonl(pMsg->tid)); } -- GitLab