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) {
|
||||
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;
|
||||
dError("failed to build msg since %s, app:%p handle:%p", terrstr(), pRpc->info.ahandle, pRpc->info.handle);
|
||||
return -1;
|
||||
|
@ -49,9 +49,9 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||
SDnodeTrans *pTrans = &pDnode->trans;
|
||||
SDnodeTrans * pTrans = &pDnode->trans;
|
||||
int32_t code = -1;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
SRpcMsg * pMsg = NULL;
|
||||
SMgmtWrapper *pWrapper = NULL;
|
||||
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) {
|
||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||
SArray *pArray = (*pWrapper->func.getHandlesFp)();
|
||||
SArray * pArray = (*pWrapper->func.getHandlesFp)();
|
||||
if (pArray == NULL) return -1;
|
||||
|
||||
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)];
|
||||
if (pMgmt->needCheckVgId) {
|
||||
pHandle->needCheckVgId = pMgmt->needCheckVgId;
|
||||
|
|
|
@ -1153,23 +1153,34 @@ _return2:
|
|||
rpcFreeCont(msg->pCont);
|
||||
}
|
||||
|
||||
int transGetConnInfo(void* thandle, STransHandleInfo* pInfo) {
|
||||
int transGetConnInfo(void* thandle, STransHandleInfo* pConnInfo) {
|
||||
if (thandle == NULL) {
|
||||
tTrace("invalid handle %p, failed to Get Conn info", thandle);
|
||||
return -1;
|
||||
}
|
||||
SExHandle* ex = thandle;
|
||||
SSvrConn* pConn = ex->handle;
|
||||
SRpcHandleInfo* pInfo = thandle;
|
||||
SExHandle* exh = pInfo->handle;
|
||||
int64_t refId = pInfo->refId;
|
||||
ASYNC_CHECK_HANDLE(exh, refId);
|
||||
|
||||
// SExHandle* ex = thandle;
|
||||
SSvrConn* pConn = exh->handle;
|
||||
if (pConn == NULL) {
|
||||
tTrace("invalid handle %p, failed to Get Conn info", thandle);
|
||||
transReleaseExHandle(refMgt, refId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct sockaddr_in addr = pConn->addr;
|
||||
pInfo->clientIp = (uint32_t)(addr.sin_addr.s_addr);
|
||||
pInfo->clientPort = ntohs(addr.sin_port);
|
||||
tstrncpy(pInfo->user, pConn->user, sizeof(pInfo->user));
|
||||
pConnInfo->clientIp = (uint32_t)(addr.sin_addr.s_addr);
|
||||
pConnInfo->clientPort = ntohs(addr.sin_port);
|
||||
tstrncpy(pConnInfo->user, pConn->user, sizeof(pConnInfo->user));
|
||||
transReleaseExHandle(refMgt, refId);
|
||||
return 0;
|
||||
_return1:
|
||||
transReleaseExHandle(refMgt, refId);
|
||||
return -1;
|
||||
_return2:
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue