Merge pull request #3186 from taosdata/bugfix/td-1127
fix two case of 'unexpected generic error in RPC'
This commit is contained in:
commit
6c95affeea
|
@ -1114,10 +1114,13 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
|
||||||
|
|
||||||
if (pHead->code == TSDB_CODE_RPC_REDIRECT) {
|
if (pHead->code == TSDB_CODE_RPC_REDIRECT) {
|
||||||
pContext->numOfTry = 0;
|
pContext->numOfTry = 0;
|
||||||
memcpy(&pContext->epSet, pHead->content, sizeof(pContext->epSet));
|
SRpcEpSet *pEpSet = (SRpcEpSet*)pHead->content;
|
||||||
tDebug("%s, redirect is received, numOfEps:%d", pConn->info, pContext->epSet.numOfEps);
|
if (pEpSet->numOfEps > 0) {
|
||||||
for (int i=0; i<pContext->epSet.numOfEps; ++i)
|
memcpy(&pContext->epSet, pHead->content, sizeof(pContext->epSet));
|
||||||
pContext->epSet.port[i] = htons(pContext->epSet.port[i]);
|
tDebug("%s, redirect is received, numOfEps:%d", pConn->info, pContext->epSet.numOfEps);
|
||||||
|
for (int i=0; i<pContext->epSet.numOfEps; ++i)
|
||||||
|
pContext->epSet.port[i] = htons(pContext->epSet.port[i]);
|
||||||
|
}
|
||||||
rpcSendReqToServer(pRpc, pContext);
|
rpcSendReqToServer(pRpc, pContext);
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
} else if (pHead->code == TSDB_CODE_RPC_NOT_READY || pHead->code == TSDB_CODE_APP_NOT_READY) {
|
} else if (pHead->code == TSDB_CODE_RPC_NOT_READY || pHead->code == TSDB_CODE_APP_NOT_READY) {
|
||||||
|
|
|
@ -19,26 +19,25 @@
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
int taosGetFqdn(char *fqdn) {
|
int taosGetFqdn(char *fqdn) {
|
||||||
int code = 0;
|
|
||||||
char hostname[1024];
|
char hostname[1024];
|
||||||
hostname[1023] = '\0';
|
hostname[1023] = '\0';
|
||||||
gethostname(hostname, 1023);
|
if (gethostname(hostname, 1023) == -1) {
|
||||||
|
uError("failed to get hostname, reason:%s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
struct addrinfo hints = {0};
|
struct addrinfo hints = {0};
|
||||||
struct addrinfo *result = NULL;
|
struct addrinfo *result = NULL;
|
||||||
|
|
||||||
hints.ai_flags = AI_CANONNAME;
|
hints.ai_flags = AI_CANONNAME;
|
||||||
|
int ret = getaddrinfo(hostname, NULL, &hints, &result);
|
||||||
int32_t ret = getaddrinfo(hostname, NULL, &hints, &result);
|
if (!result) {
|
||||||
if (result) {
|
|
||||||
strcpy(fqdn, result->ai_canonname);
|
|
||||||
freeaddrinfo(result);
|
|
||||||
} else {
|
|
||||||
uError("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
|
uError("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
|
||||||
code = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
strcpy(fqdn, result->ai_canonname);
|
||||||
|
freeaddrinfo(result);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t taosGetIpFromFqdn(const char *fqdn) {
|
uint32_t taosGetIpFromFqdn(const char *fqdn) {
|
||||||
|
|
Loading…
Reference in New Issue