提交 0293a091 编写于 作者: dengyihao's avatar dengyihao

enh: return NULL when epset not updated

上级 79e447da
...@@ -112,7 +112,8 @@ typedef struct SCvtAddr { ...@@ -112,7 +112,8 @@ typedef struct SCvtAddr {
} SCvtAddr; } SCvtAddr;
typedef struct { typedef struct {
SEpSet epSet; // ip list provided by app SEpSet epSet; // ip list provided by app
SEpSet origEpSet;
void* ahandle; // handle provided by app void* ahandle; // handle provided by app
tmsg_t msgType; // message type tmsg_t msgType; // message type
int8_t connType; // connection type cli/srv int8_t connType; // connection type cli/srv
...@@ -344,6 +345,7 @@ void transDQDestroy(SDelayQueue* queue); ...@@ -344,6 +345,7 @@ void transDQDestroy(SDelayQueue* queue);
int transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs); int transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs);
void transPrintEpSet(SEpSet* pEpSet); void transPrintEpSet(SEpSet* pEpSet);
bool transEpSetIsEqual(SEpSet* a, SEpSet* b);
/* /*
* init global func * init global func
*/ */
......
...@@ -947,6 +947,9 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { ...@@ -947,6 +947,9 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
SEpSet* pEpSet = &pCtx->epSet; SEpSet* pEpSet = &pCtx->epSet;
transPrintEpSet(pEpSet); transPrintEpSet(pEpSet);
if (pCtx->retryCount == 0) {
pCtx->origEpSet = pCtx->epSet;
}
/* /*
* upper layer handle retry if code equal TSDB_CODE_RPC_NETWORK_UNAVAIL * upper layer handle retry if code equal TSDB_CODE_RPC_NETWORK_UNAVAIL
*/ */
...@@ -999,7 +1002,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { ...@@ -999,7 +1002,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
pCtx->pRsp = NULL; pCtx->pRsp = NULL;
} else { } else {
tTrace("%s cli conn %p handle resp", pTransInst->label, pConn); tTrace("%s cli conn %p handle resp", pTransInst->label, pConn);
if (pResp->code != 0) { if (pResp->code != 0 || pCtx->retryCount == 0 || transEpSetIsEqual(&pCtx->epSet, &pCtx->origEpSet)) {
pTransInst->cfp(pTransInst->parent, pResp, NULL); pTransInst->cfp(pTransInst->parent, pResp, NULL);
} else { } else {
pTransInst->cfp(pTransInst->parent, pResp, pEpSet); pTransInst->cfp(pTransInst->parent, pResp, pEpSet);
......
...@@ -453,10 +453,21 @@ void transPrintEpSet(SEpSet* pEpSet) { ...@@ -453,10 +453,21 @@ void transPrintEpSet(SEpSet* pEpSet) {
tTrace("NULL epset"); tTrace("NULL epset");
return; return;
} }
tTrace("epset begin: inUse: %d", pEpSet->inUse); tTrace("epset begin inUse: %d", pEpSet->inUse);
for (int i = 0; i < pEpSet->numOfEps; i++) { for (int i = 0; i < pEpSet->numOfEps; i++) {
tTrace("ip: %s, port: %d", pEpSet->eps[i].fqdn, pEpSet->eps[i].port); tTrace("ip: %s, port: %d", pEpSet->eps[i].fqdn, pEpSet->eps[i].port);
} }
tTrace("epset end"); tTrace("epset end");
} }
bool transEpSetIsEqual(SEpSet* a, SEpSet* b) {
if (a->numOfEps != b->numOfEps || a->inUse != b->inUse) {
return false;
}
for (int i = 0; i < a->numOfEps; i++) {
if (strncmp(a->eps[i].fqdn, b->eps[i].fqdn, TSDB_FQDN_LEN) != 0 || a->eps[i].port != b->eps[i].port) {
return false;
}
}
return true;
}
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册