Merge branch 'feature/queryredirect' of github.com:taosdata/TDengine into feature/queryredirect
This commit is contained in:
commit
1b3eec48bd
|
@ -41,6 +41,7 @@ static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
||||
pMsg->info.hasEpSet = 1;
|
||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||
int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet);
|
||||
|
||||
|
|
|
@ -552,6 +552,7 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
|||
|
||||
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
||||
pMsg->info.rsp = rpcMallocCont(contLen);
|
||||
pMsg->info.hasEpSet = 1;
|
||||
if (pMsg->info.rsp != NULL) {
|
||||
tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet);
|
||||
pMsg->info.rspLen = contLen;
|
||||
|
|
|
@ -178,7 +178,7 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
|||
for (int32_t i = 0; i < newEpSet.numOfEps; ++i) {
|
||||
vGTrace("vgId:%d, msg:%p redirect:%d ep:%s:%u", vgId, pMsg, i, newEpSet.eps[i].fqdn, newEpSet.eps[i].port);
|
||||
}
|
||||
|
||||
pMsg->info.hasEpSet = 1;
|
||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
||||
} else {
|
||||
|
|
|
@ -1014,19 +1014,28 @@ void cliCompareAndSwap(int8_t* val, int8_t exp, int8_t newVal) {
|
|||
}
|
||||
|
||||
bool cliTryToExtractEpSet(STransMsg* pResp, SEpSet* dst) {
|
||||
if (pResp == NULL || pResp->info.hasEpSet == 0) {
|
||||
if ((pResp == NULL || pResp->info.hasEpSet == 0)) {
|
||||
return false;
|
||||
}
|
||||
// rebuild resp msg
|
||||
SEpSet epset;
|
||||
if (tDeserializeSEpSet(pResp->pCont, pResp->contLen, &epset) < 0) {
|
||||
return false;
|
||||
}
|
||||
tDeserializeSEpSet(pResp->pCont, pResp->contLen, dst);
|
||||
int32_t tlen = tSerializeSEpSet(NULL, 0, dst);
|
||||
|
||||
int32_t bufLen = pResp->contLen - tlen;
|
||||
char* buf = rpcMallocCont(bufLen);
|
||||
|
||||
memcpy(buf, (char*)pResp->pCont + tlen, bufLen);
|
||||
char* buf = NULL;
|
||||
int32_t len = pResp->contLen - tlen;
|
||||
if (len != 0) {
|
||||
buf = rpcMallocCont(len);
|
||||
memcpy(buf, (char*)pResp->pCont + tlen, len);
|
||||
}
|
||||
rpcFreeCont(pResp->pCont);
|
||||
|
||||
pResp->pCont = buf;
|
||||
pResp->contLen = bufLen;
|
||||
pResp->contLen = len;
|
||||
|
||||
*dst = epset;
|
||||
return true;
|
||||
}
|
||||
int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
||||
|
|
Loading…
Reference in New Issue