refactor: free rpcCont on error occured
This commit is contained in:
parent
92e2d9612f
commit
44d9cc8d57
|
@ -16,8 +16,9 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
|
|
||||||
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet);
|
static void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet);
|
||||||
static inline void dmSendRsp(SRpcMsg *pMsg);
|
static void dmSendRsp(SRpcMsg *pMsg);
|
||||||
|
static void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
static inline int32_t dmBuildNodeMsg(SRpcMsg *pMsg, SRpcMsg *pRpc) {
|
static inline int32_t dmBuildNodeMsg(SRpcMsg *pMsg, SRpcMsg *pRpc) {
|
||||||
SRpcConnInfo connInfo = {0};
|
SRpcConnInfo connInfo = {0};
|
||||||
|
@ -130,23 +131,17 @@ _OVER:
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
|
|
||||||
if (IsReq(pRpc)) {
|
if (IsReq(pRpc)) {
|
||||||
|
SRpcMsg rsp = {.code = code, .info = pRpc->info};
|
||||||
|
|
||||||
if ((code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_APP_NOT_READY) && pRpc->msgType > TDMT_MND_MSG &&
|
if ((code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_APP_NOT_READY) && pRpc->msgType > TDMT_MND_MSG &&
|
||||||
pRpc->msgType < TDMT_VND_MSG) {
|
pRpc->msgType < TDMT_VND_MSG) {
|
||||||
SEpSet epset = {0};
|
dmBuildMnodeRedirectRsp(pDnode, &rsp);
|
||||||
dmGetMnodeEpSetForRedirect(&pDnode->data, pMsg, &epset);
|
}
|
||||||
SRpcMsg rsp = {.code = TSDB_CODE_NODE_REDIRECT, .info = pRpc->info};
|
|
||||||
if (pWrapper != NULL) {
|
if (pWrapper != NULL) {
|
||||||
dmSendRedirectRsp(&rsp, &epset);
|
dmSendRsp(&rsp);
|
||||||
} else {
|
|
||||||
rpcSendRedirectRsp(&rsp, &epset);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
SRpcMsg rsp = {.code = code, .info = pRpc->info};
|
rpcSendResponse(&rsp);
|
||||||
if (pWrapper != NULL) {
|
|
||||||
dmSendRsp(&rsp);
|
|
||||||
} else {
|
|
||||||
rpcSendResponse(&rsp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,6 +202,20 @@ static inline void dmSendRsp(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
|
SMEpSet msg = {0};
|
||||||
|
dmGetMnodeEpSetForRedirect(&pDnode->data, pMsg, &msg.epSet);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMEpSet(NULL, 0, &msg);
|
||||||
|
pMsg->pCont = rpcMallocCont(contLen);
|
||||||
|
if (pMsg->pCont == NULL) {
|
||||||
|
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
} else {
|
||||||
|
tSerializeSMEpSet(pMsg->pCont, contLen, &msg);
|
||||||
|
pMsg->contLen = contLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
||||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||||
SMEpSet msg = {.epSet = *pNewEpSet};
|
SMEpSet msg = {.epSet = *pNewEpSet};
|
||||||
|
|
Loading…
Reference in New Issue