refact code

This commit is contained in:
yihaoDeng 2024-07-31 21:22:39 +08:00 committed by wangjiaming0909
parent 188883341a
commit 11b91adddf
2 changed files with 12 additions and 10 deletions

View File

@ -148,7 +148,6 @@ typedef struct {
STransSyncMsg* pSyncMsg; // for syncchronous with timeout API STransSyncMsg* pSyncMsg; // for syncchronous with timeout API
int64_t syncMsgRef; int64_t syncMsgRef;
SCvtAddr cvtAddr; SCvtAddr cvtAddr;
bool setMaxRetry;
int32_t retryMinInterval; int32_t retryMinInterval;
int32_t retryMaxInterval; int32_t retryMaxInterval;

View File

@ -1605,12 +1605,13 @@ static void cliHandleFreeById(SCliMsg* pMsg, SCliThrd* pThrd) {
SCliConn* conn = exh->handle; SCliConn* conn = exh->handle;
taosRUnLockLatch(&exh->latch); taosRUnLockLatch(&exh->latch);
if (conn->refId != refId) { if (conn == NULL || conn->refId != refId) {
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _except); TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _except);
} }
int32_t size = transQueueSize(&conn->cliMsgs); int32_t size = transQueueSize(&conn->cliMsgs);
if (size == 0) { if (size == 0) {
// already recv, and notify upper layer
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _except); TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _except);
return; return;
} else { } else {
@ -3178,20 +3179,20 @@ _RETURN2:
* *
**/ **/
int32_t transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { int32_t transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
if (ip == NULL || fqdn == NULL) return TSDB_CODE_INVALID_PARA;
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
if (pTransInst == NULL) { if (pTransInst == NULL) {
return TSDB_CODE_RPC_MODULE_QUIT; return TSDB_CODE_RPC_MODULE_QUIT;
} }
SCvtAddr cvtAddr = {0}; SCvtAddr cvtAddr = {0};
if (ip != NULL && fqdn != NULL) { tstrncpy(cvtAddr.ip, ip, sizeof(cvtAddr.ip));
tstrncpy(cvtAddr.ip, ip, sizeof(cvtAddr.ip)); tstrncpy(cvtAddr.fqdn, fqdn, sizeof(cvtAddr.fqdn));
tstrncpy(cvtAddr.fqdn, fqdn, sizeof(cvtAddr.fqdn)); cvtAddr.cvt = true;
cvtAddr.cvt = true;
}
int32_t code = 0; int32_t code = 0;
int8_t i = 0; for (int8_t i = 0; i < pTransInst->numOfThreads; i++) {
for (i = 0; i < pTransInst->numOfThreads; i++) {
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
if (pCtx == NULL) { if (pCtx == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
@ -3216,7 +3217,9 @@ int32_t transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
if ((code = transAsyncSend(thrd->asyncPool, &(cliMsg->q))) != 0) { if ((code = transAsyncSend(thrd->asyncPool, &(cliMsg->q))) != 0) {
destroyCmsg(cliMsg); destroyCmsg(cliMsg);
code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); if (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT) {
code = TSDB_CODE_RPC_MODULE_QUIT;
}
break; break;
} }
} }