add pre check
This commit is contained in:
parent
ee5794f494
commit
74b6e98b76
|
@ -186,6 +186,8 @@ typedef struct {
|
||||||
int32_t transCreateReqEpsetFromUserEpset(const SEpSet* pEpset, SReqEpSet** pReqEpSet);
|
int32_t transCreateReqEpsetFromUserEpset(const SEpSet* pEpset, SReqEpSet** pReqEpSet);
|
||||||
int32_t transCreateUserEpsetFromReqEpset(const SReqEpSet* pReqEpSet, SEpSet* pEpSet);
|
int32_t transCreateUserEpsetFromReqEpset(const SReqEpSet* pReqEpSet, SEpSet* pEpSet);
|
||||||
|
|
||||||
|
int32_t transValidReqEpset(SReqEpSet* pReqEpSet);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SReqEpSet* epSet; // ip list provided by app
|
SReqEpSet* epSet; // ip list provided by app
|
||||||
SReqEpSet* origEpSet;
|
SReqEpSet* origEpSet;
|
||||||
|
|
|
@ -2936,7 +2936,7 @@ static int32_t transInitMsg(void* pInstRef, const SEpSet* pEpSet, STransMsg* pRe
|
||||||
*pCliMsg = pCliReq;
|
*pCliMsg = pCliReq;
|
||||||
return code;
|
return code;
|
||||||
_exception:
|
_exception:
|
||||||
if (pCtx == NULL) {
|
if (pCtx != NULL) {
|
||||||
taosMemoryFree(pCtx->epSet);
|
taosMemoryFree(pCtx->epSet);
|
||||||
taosMemoryFree(pCtx->origEpSet);
|
taosMemoryFree(pCtx->origEpSet);
|
||||||
taosMemoryFree(pCtx);
|
taosMemoryFree(pCtx);
|
||||||
|
@ -2979,6 +2979,9 @@ _exception:
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
pReq->pCont = NULL;
|
pReq->pCont = NULL;
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
||||||
|
if (code != 0) {
|
||||||
|
tError("failed to send request since %s", tstrerror(code));
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
int32_t transSendRequestWithId(void* pInstRef, const SEpSet* pEpSet, STransMsg* pReq, int64_t* transpointId) {
|
int32_t transSendRequestWithId(void* pInstRef, const SEpSet* pEpSet, STransMsg* pReq, int64_t* transpointId) {
|
||||||
|
@ -3025,6 +3028,8 @@ _exception:
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
pReq->pCont = NULL;
|
pReq->pCont = NULL;
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef);
|
||||||
|
|
||||||
|
tError("failed to send request since %s", tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -957,8 +957,14 @@ int32_t transCreateReqEpsetFromUserEpset(const SEpSet* pEpset, SReqEpSet** pReqE
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
memcpy((char*)pReq, (char*)pEpset, size);
|
memcpy((char*)pReq, (char*)pEpset, size);
|
||||||
|
// clear previous
|
||||||
taosMemoryFree(*pReqEpSet);
|
taosMemoryFree(*pReqEpSet);
|
||||||
|
|
||||||
|
if (transValidReqEpset(pReq) != TSDB_CODE_SUCCESS) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
*pReqEpSet = pReq;
|
*pReqEpSet = pReq;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -969,4 +975,14 @@ int32_t transCreateUserEpsetFromReqEpset(const SReqEpSet* pReqEpSet, SEpSet* pEp
|
||||||
}
|
}
|
||||||
memcpy((char*)pEpSet, (char*)pReqEpSet, sizeof(SReqEpSet) + sizeof(SEp) * pReqEpSet->numOfEps);
|
memcpy((char*)pEpSet, (char*)pReqEpSet, sizeof(SReqEpSet) + sizeof(SEp) * pReqEpSet->numOfEps);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t transValidReqEpset(SReqEpSet* pReqEpSet) {
|
||||||
|
if (pReqEpSet == NULL) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
if (pReqEpSet->numOfEps == 0 || pReqEpSet->numOfEps > TSDB_MAX_EP_NUM || pReqEpSet->inUse >= TSDB_MAX_EP_NUM) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
Loading…
Reference in New Issue