fix: avoid invalid conn
This commit is contained in:
parent
e17b2e386b
commit
4e6010f59b
|
@ -23,7 +23,7 @@ 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};
|
||||||
if (IsReq(pRpc) && rpcGetConnInfo(pRpc->info.handle, &connInfo) != 0) {
|
if (IsReq(pRpc) && rpcGetConnInfo(&pRpc->info, &connInfo) != 0) {
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
dError("failed to build msg since %s, app:%p handle:%p", terrstr(), pRpc->info.ahandle, pRpc->info.handle);
|
dError("failed to build msg since %s, app:%p handle:%p", terrstr(), pRpc->info.ahandle, pRpc->info.handle);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -49,9 +49,9 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans * pTrans = &pDnode->trans;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SRpcMsg *pMsg = NULL;
|
SRpcMsg * pMsg = NULL;
|
||||||
SMgmtWrapper *pWrapper = NULL;
|
SMgmtWrapper *pWrapper = NULL;
|
||||||
SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pRpc->msgType)];
|
SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pRpc->msgType)];
|
||||||
|
|
||||||
|
@ -167,11 +167,11 @@ int32_t dmInitMsgHandle(SDnode *pDnode) {
|
||||||
|
|
||||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
SArray *pArray = (*pWrapper->func.getHandlesFp)();
|
SArray * pArray = (*pWrapper->func.getHandlesFp)();
|
||||||
if (pArray == NULL) return -1;
|
if (pArray == NULL) return -1;
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||||
SMgmtHandle *pMgmt = taosArrayGet(pArray, i);
|
SMgmtHandle * pMgmt = taosArrayGet(pArray, i);
|
||||||
SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)];
|
SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)];
|
||||||
if (pMgmt->needCheckVgId) {
|
if (pMgmt->needCheckVgId) {
|
||||||
pHandle->needCheckVgId = pMgmt->needCheckVgId;
|
pHandle->needCheckVgId = pMgmt->needCheckVgId;
|
||||||
|
|
|
@ -1153,23 +1153,34 @@ _return2:
|
||||||
rpcFreeCont(msg->pCont);
|
rpcFreeCont(msg->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
int transGetConnInfo(void* thandle, STransHandleInfo* pInfo) {
|
int transGetConnInfo(void* thandle, STransHandleInfo* pConnInfo) {
|
||||||
if (thandle == NULL) {
|
if (thandle == NULL) {
|
||||||
tTrace("invalid handle %p, failed to Get Conn info", thandle);
|
tTrace("invalid handle %p, failed to Get Conn info", thandle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SExHandle* ex = thandle;
|
SRpcHandleInfo* pInfo = thandle;
|
||||||
SSvrConn* pConn = ex->handle;
|
SExHandle* exh = pInfo->handle;
|
||||||
|
int64_t refId = pInfo->refId;
|
||||||
|
ASYNC_CHECK_HANDLE(exh, refId);
|
||||||
|
|
||||||
|
// SExHandle* ex = thandle;
|
||||||
|
SSvrConn* pConn = exh->handle;
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
tTrace("invalid handle %p, failed to Get Conn info", thandle);
|
tTrace("invalid handle %p, failed to Get Conn info", thandle);
|
||||||
|
transReleaseExHandle(refMgt, refId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_in addr = pConn->addr;
|
struct sockaddr_in addr = pConn->addr;
|
||||||
pInfo->clientIp = (uint32_t)(addr.sin_addr.s_addr);
|
pConnInfo->clientIp = (uint32_t)(addr.sin_addr.s_addr);
|
||||||
pInfo->clientPort = ntohs(addr.sin_port);
|
pConnInfo->clientPort = ntohs(addr.sin_port);
|
||||||
tstrncpy(pInfo->user, pConn->user, sizeof(pInfo->user));
|
tstrncpy(pConnInfo->user, pConn->user, sizeof(pConnInfo->user));
|
||||||
|
transReleaseExHandle(refMgt, refId);
|
||||||
return 0;
|
return 0;
|
||||||
|
_return1:
|
||||||
|
transReleaseExHandle(refMgt, refId);
|
||||||
|
return -1;
|
||||||
|
_return2:
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue