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;
|
||||
|
|
|
@ -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;
|
||||
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;
|
||||
}
|
||||
|
||||
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));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue