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) {
|
||||
pContext->numOfTry = 0;
|
||||
memcpy(&pContext->epSet, pHead->content, sizeof(pContext->epSet));
|
||||
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]);
|
||||
SRpcEpSet *pEpSet = (SRpcEpSet*)pHead->content;
|
||||
if (pEpSet->numOfEps > 0) {
|
||||
memcpy(&pContext->epSet, pHead->content, sizeof(pContext->epSet));
|
||||
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);
|
||||
rpcFreeCont(rpcMsg.pCont);
|
||||
} else if (pHead->code == TSDB_CODE_RPC_NOT_READY || pHead->code == TSDB_CODE_APP_NOT_READY) {
|
||||
|
|
|
@ -19,26 +19,25 @@
|
|||
#include "tutil.h"
|
||||
|
||||
int taosGetFqdn(char *fqdn) {
|
||||
int code = 0;
|
||||
char hostname[1024];
|
||||
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 *result = NULL;
|
||||
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
|
||||
int32_t ret = getaddrinfo(hostname, NULL, &hints, &result);
|
||||
if (result) {
|
||||
strcpy(fqdn, result->ai_canonname);
|
||||
freeaddrinfo(result);
|
||||
} else {
|
||||
int ret = getaddrinfo(hostname, NULL, &hints, &result);
|
||||
if (!result) {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue