From 0164158256daf9fad228cf24918e57d0463aeb52 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 18 May 2022 18:37:39 +0800 Subject: [PATCH] refactor: adjust msgcb --- include/common/tmsgcb.h | 6 ++-- source/common/src/tmsgcb.c | 28 +++++++++---------- source/dnode/mgmt/node_mgmt/src/dmNodes.c | 2 +- source/dnode/mnode/impl/test/trans/trans2.cpp | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index 7ba6e5044c..9fa657a2a6 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -60,9 +60,9 @@ typedef struct { ReportStartup reportStartupFp; } SMsgCb; -void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb); -int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pMsg); -int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype); +void tmsgSetDefault(const SMsgCb* msgcb); +int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg); +int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype); int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg); void tmsgSendRsp(SRpcMsg* pMsg); void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet); diff --git a/source/common/src/tmsgcb.c b/source/common/src/tmsgcb.c index f69fb65f04..126a4c023a 100644 --- a/source/common/src/tmsgcb.c +++ b/source/common/src/tmsgcb.c @@ -17,46 +17,46 @@ #include "tmsgcb.h" #include "taoserror.h" -static SMsgCb tsDefaultMsgCb; +static SMsgCb defaultMsgCb; -void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb) { tsDefaultMsgCb = *pMsgCb; } +void tmsgSetDefault(const SMsgCb* msgcb) { defaultMsgCb = *msgcb; } -int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pMsg) { - PutToQueueFp fp = pMsgCb->queueFps[qtype]; - return (*fp)(pMsgCb->mgmt, pMsg); +int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg) { + PutToQueueFp fp = msgcb->queueFps[qtype]; + return (*fp)(msgcb->mgmt, pMsg); } -int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype) { - GetQueueSizeFp fp = pMsgCb->qsizeFp; - return (*fp)(pMsgCb->mgmt, vgId, qtype); +int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype) { + GetQueueSizeFp fp = msgcb->qsizeFp; + return (*fp)(msgcb->mgmt, vgId, qtype); } int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg) { - SendReqFp fp = tsDefaultMsgCb.sendReqFp; + SendReqFp fp = defaultMsgCb.sendReqFp; return (*fp)(epSet, pMsg); } void tmsgSendRsp(SRpcMsg* pMsg) { - SendRspFp fp = tsDefaultMsgCb.sendRspFp; + SendRspFp fp = defaultMsgCb.sendRspFp; return (*fp)(pMsg); } void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet) { - SendRedirectRspFp fp = tsDefaultMsgCb.sendRedirectRspFp; + SendRedirectRspFp fp = defaultMsgCb.sendRedirectRspFp; (*fp)(pMsg, pNewEpSet); } void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) { - RegisterBrokenLinkArgFp fp = tsDefaultMsgCb.registerBrokenLinkArgFp; + RegisterBrokenLinkArgFp fp = defaultMsgCb.registerBrokenLinkArgFp; (*fp)(pMsg); } void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) { - ReleaseHandleFp fp = tsDefaultMsgCb.releaseHandleFp; + ReleaseHandleFp fp = defaultMsgCb.releaseHandleFp; (*fp)(pHandle, type); } void tmsgReportStartup(const char* name, const char* desc) { - ReportStartup fp = tsDefaultMsgCb.reportStartupFp; + ReportStartup fp = defaultMsgCb.reportStartupFp; (*fp)(name, desc); } \ No newline at end of file diff --git a/source/dnode/mgmt/node_mgmt/src/dmNodes.c b/source/dnode/mgmt/node_mgmt/src/dmNodes.c index 3a26388d14..ecfa37725a 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmNodes.c +++ b/source/dnode/mgmt/node_mgmt/src/dmNodes.c @@ -78,7 +78,7 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) { SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); if (pWrapper->ntype == DNODE || InChildProc(pWrapper)) { - tmsgSetDefaultMsgCb(&input.msgCb); + tmsgSetDefault(&input.msgCb); } if (OnlyInSingleProc(pWrapper)) { diff --git a/source/dnode/mnode/impl/test/trans/trans2.cpp b/source/dnode/mnode/impl/test/trans/trans2.cpp index 82acd7fddc..c4ed48fe60 100644 --- a/source/dnode/mnode/impl/test/trans/trans2.cpp +++ b/source/dnode/mnode/impl/test/trans/trans2.cpp @@ -56,7 +56,7 @@ class MndTestTrans2 : public ::testing::Test { msgCb.sendReqFp = sendReq; msgCb.sendRspFp = sendRsp; msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack - tmsgSetDefaultMsgCb(&msgCb); + tmsgSetDefault(&msgCb); SMnodeOpt opt = {0}; opt.deploy = 1; -- GitLab