Merge pull request #1767 from taosdata/hotfix/rpcSid
if not master, authentication shall return NOT_READY, so client can m…
This commit is contained in:
commit
222f78a757
|
@ -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);
|
||||
|
|
|
@ -613,13 +613,15 @@ 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);
|
||||
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
|
||||
terrno = TSDB_CODE_INVALID_USER;
|
||||
pConn = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pConn) {
|
||||
if (pRecv->connType == RPC_CONN_UDPS && pRpc->numOfThreads > 1) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue