提交 cf3f7ef4 编写于 作者: J jtao1735

if not master, authentication shall return NOT_READY, so client can move to next node

上级 f0bbe277
......@@ -375,7 +375,7 @@ static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secr
if (!sdbIsMaster()) {
*secret = 0;
return TSDB_CODE_SUCCESS;
return TSDB_CODE_NOT_READY;
}
SUserObj *pUser = mgmtGetUser(user);
......@@ -594,4 +594,4 @@ void* mgmtCloneQueuedMsg(SQueuedMsg *pSrcMsg) {
pSrcMsg->pUser = NULL;
return pDestMsg;
}
\ No newline at end of file
}
......@@ -613,11 +613,13 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pConn->tranId = (uint16_t)(rand() & 0xFFFF);
pConn->ownId = htonl(pConn->sid);
pConn->linkUid = pHead->linkUid;
if (pRpc->afp && (*pRpc->afp)(pConn->user, &pConn->spi, &pConn->encrypt, pConn->secret, pConn->ckey) < 0) {
tWarn("%s %p, user not there", pRpc->label, pConn);
taosFreeId(pRpc->idPool, sid); // sid shall be released
terrno = TSDB_CODE_INVALID_USER;
pConn = NULL;
if (pRpc->afp) {
terrno = (*pRpc->afp)(pConn->user, &pConn->spi, &pConn->encrypt, pConn->secret, pConn->ckey);
if (terrno != 0) {
tWarn("%s %p, user not there or server not ready", pRpc->label, pConn);
taosFreeId(pRpc->idPool, sid); // sid shall be released
pConn = NULL;
}
}
}
......@@ -1334,7 +1336,8 @@ static int rpcCheckAuthentication(SRpcConn *pConn, char *msg, int msgLen) {
if ( !rpcIsReq(pHead->msgType) ) {
// for response, if code is auth failure, it shall bypass the auth process
code = htonl(pHead->code);
if (code==TSDB_CODE_INVALID_TIME_STAMP || code==TSDB_CODE_AUTH_FAILURE || code==TSDB_CODE_INVALID_USER) {
if (code==TSDB_CODE_INVALID_TIME_STAMP || code==TSDB_CODE_AUTH_FAILURE ||
code==TSDB_CODE_INVALID_USER || code == TSDB_CODE_NOT_READY) {
pHead->msgLen = (int32_t)htonl((uint32_t)pHead->msgLen);
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册