diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index 7ba6e5044c35b09ddf4cefea2509909c0e340c37..9fa657a2a6ad78fdd70ed1b4e2ed816b06780351 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 f69fb65f04492452c240a2fa647e822d523f1d8c..126a4c023a09505c8b93174c622e14654aa71b0f 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/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 5dc5b6cef25ac1eed2cf12f13bd4615da3f5cc09..30d7750f79c2aa31cac179f4228d27147e282180 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -275,7 +275,7 @@ static void dmGetServerStartupStatus(SDnode *pDnode, SServerStatusRsp *pStatus) } void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) { - dDebug("start to process net test req"); + dDebug("msg:%p, net test req will be processed", pMsg); SRpcMsg rsp = {.code = 0, .info = pMsg->info}; rsp.pCont = rpcMallocCont(pMsg->contLen); if (rsp.pCont == NULL) { @@ -287,8 +287,7 @@ void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) { } void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) { - dDebug("start to process server startup status req"); - + dDebug("msg:%p, server startup status req will be processed", pMsg); SServerStatusRsp statusRsp = {0}; dmGetServerStartupStatus(pDnode, &statusRsp); diff --git a/source/dnode/mgmt/node_mgmt/src/dmNodes.c b/source/dnode/mgmt/node_mgmt/src/dmNodes.c index 3a26388d14814f20dcb6745c6315b3a6e3f03bda..ecfa37725a86f368eb5f9b84247d741900823abd 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/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index f66bc84def61c2e590bd116edf9423a78ef074b0..b4c8a0807c8f636953de92bee9d5584e6eb877d5 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -344,66 +344,6 @@ void dmCleanupClient(SDnode *pDnode) { } } -static inline int32_t dmGetHideUserAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) { - int32_t code = 0; - char pass[TSDB_PASSWORD_LEN + 1] = {0}; - - if (strcmp(user, INTERNAL_USER) == 0) { - taosEncryptPass_c((uint8_t *)(INTERNAL_SECRET), strlen(INTERNAL_SECRET), pass); - } else if (strcmp(user, TSDB_NETTEST_USER) == 0) { - taosEncryptPass_c((uint8_t *)(TSDB_NETTEST_USER), strlen(TSDB_NETTEST_USER), pass); - } else { - code = -1; - } - - if (code == 0) { - memcpy(secret, pass, TSDB_PASSWORD_LEN); - *spi = 1; - *encrypt = 0; - *ckey = 0; - } - - return code; -} - -static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret, - char *ckey) { - if (dmGetHideUserAuth(user, spi, encrypt, secret, ckey) == 0) { - dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt); - return 0; - } - - SAuthReq authReq = {0}; - tstrncpy(authReq.user, user, TSDB_USER_LEN); - int32_t contLen = tSerializeSAuthReq(NULL, 0, &authReq); - void *pReq = rpcMallocCont(contLen); - tSerializeSAuthReq(pReq, contLen, &authReq); - - SRpcMsg rpcMsg = {.pCont = pReq, .contLen = contLen, .msgType = TDMT_MND_AUTH, .info.ahandle = (void *)9528}; - SRpcMsg rpcRsp = {0}; - SEpSet epSet = {0}; - dTrace("user:%s, send user auth req to other mnodes, spi:%d encrypt:%d", user, authReq.spi, authReq.encrypt); - dmGetMnodeEpSet(&pDnode->data, &epSet); - dmSendRecv(&epSet, &rpcMsg, &rpcRsp); - - if (rpcRsp.code != 0) { - terrno = rpcRsp.code; - dError("user:%s, failed to get user auth from other mnodes since %s", user, terrstr()); - } else { - SAuthRsp authRsp = {0}; - tDeserializeSAuthReq(rpcRsp.pCont, rpcRsp.contLen, &authRsp); - memcpy(secret, authRsp.secret, TSDB_PASSWORD_LEN); - memcpy(ckey, authRsp.ckey, TSDB_PASSWORD_LEN); - *spi = authRsp.spi; - *encrypt = authRsp.encrypt; - dTrace("user:%s, success to get user auth from other mnodes, spi:%d encrypt:%d", user, authRsp.spi, - authRsp.encrypt); - } - - rpcFreeCont(rpcRsp.pCont); - return rpcRsp.code; -} - int32_t dmInitServer(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; @@ -416,7 +356,6 @@ int32_t dmInitServer(SDnode *pDnode) { rpcInit.sessions = tsMaxShellConns; rpcInit.connType = TAOS_CONN_SERVER; rpcInit.idleTime = tsShellActivityTimer * 1000; - rpcInit.afp = (RpcAfp)dmRetrieveUserAuthInfo; rpcInit.parent = pDnode; pTrans->serverRpc = rpcOpen(&rpcInit); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 5cf2a367312c594beff675cdf6429946012a6a28..7e99c5583d69fcf708d39206aab3ccca448ddeb8 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -197,8 +197,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { goto CONN_OVER; } if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1)) { - mError("user:%s, failed to auth while acquire user, input:%s saved:%s", pReq->conn.user, connReq.passwd, - pUser->pass); + mError("user:%s, failed to auth while acquire user, input:%s", pReq->conn.user, connReq.passwd); code = TSDB_CODE_RPC_AUTH_FAILURE; goto CONN_OVER; } diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 3dfba4eca73b8c4f8c36c73fae81c8d1a56eeb04..5326376bda77a5e846e0be6ddd68ae254437beda 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -343,19 +343,20 @@ void mndStop(SMnode *pMnode) { return mndCleanupTimer(pMnode); } int32_t mndProcessMsg(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; void *ahandle = pMsg->info.ahandle; - mTrace("msg:%p, will be processed, type:%s app:%p", pMsg, TMSG_INFO(pMsg->msgType), ahandle); - if (IsReq(pMsg) && !mndIsMaster(pMnode)) { - terrno = TSDB_CODE_APP_NOT_READY; - mDebug("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle); - return -1; - } + if (IsReq(pMsg)) { + if (!mndIsMaster(pMnode)) { + terrno = TSDB_CODE_APP_NOT_READY; + mDebug("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle); + return -1; + } - if (IsReq(pMsg) && (pMsg->contLen == 0 || pMsg->pCont == NULL)) { - terrno = TSDB_CODE_INVALID_MSG_LEN; - mError("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle); - return -1; + if (pMsg->contLen == 0 || pMsg->pCont == NULL) { + terrno = TSDB_CODE_INVALID_MSG_LEN; + mError("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle); + return -1; + } } MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(pMsg->msgType)]; diff --git a/source/dnode/mnode/impl/test/trans/trans2.cpp b/source/dnode/mnode/impl/test/trans/trans2.cpp index 82acd7fddc2fe44607095898853f9ebc3b658f4f..c4ed48fe60f069b05ca445c271a54d53bff810da 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;