diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 8682672355bfae43839f31dced77d4a57b07395d..886716ebcf63eb4e54efec97347e6d216c08d8de 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -62,7 +62,7 @@ void tscPrintMgmtIp() { void tscSetMgmtIpListFromCluster(SRpcIpSet *pIpList) { tscMgmtIpList.numOfIps = htons(pIpList->numOfIps); - tscMgmtIpList.index = htons(pIpList->index); + tscMgmtIpList.inUse = htons(pIpList->inUse); tscMgmtIpList.port = htons(pIpList->port); for (int32_t i = 0; i ip[i]; @@ -72,7 +72,7 @@ void tscSetMgmtIpListFromCluster(SRpcIpSet *pIpList) { void tscSetMgmtIpListFromEdge() { if (tscMgmtIpList.numOfIps != 1) { tscMgmtIpList.numOfIps = 1; - tscMgmtIpList.index = 0; + tscMgmtIpList.inUse = 0; tscMgmtIpList.port = tsMgmtShellPort; tscMgmtIpList.ip[0] = inet_addr(tsMasterIp); tscTrace("edge mgmt IP list:"); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index cec84450ffc64a9c6390d4a75a726075730c6f23..280b091cdadfccd7ee9d0c17f052709aec0a6753 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -65,7 +65,7 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const } if (ip && ip[0]) { - tscMgmtIpList.index = 0; + tscMgmtIpList.inUse = 0; tscMgmtIpList.port = tsMgmtShellPort; tscMgmtIpList.numOfIps = 1; tscMgmtIpList.ip[0] = inet_addr(ip); diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index f805bfa4a8d409b6c39ca81a4f7d3da6d15836f7..6e4653c2d442e58e6d8cfa58a4ed402dc44b725a 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -150,7 +150,7 @@ void taos_init_imp() { taosInitNote(tsNumOfLogLines / 10, 1, (char*)"tsc_note"); } - tscMgmtIpList.index = 0; + tscMgmtIpList.inUse = 0; tscMgmtIpList.port = tsMgmtShellPort; tscMgmtIpList.numOfIps = 1; tscMgmtIpList.ip[0] = inet_addr(tsMasterIp); diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index da1a1b85340cc85664418d79eaa8df3d73668f9e..63e8a4e32f5d5b796e2e95412eab6955b6f4c43c 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -944,7 +944,7 @@ int32_t mgmtProcessHeartBeatMsg(void *pCont, int32_t contLen, void *ahandle) { SRpcConnInfo connInfo; rpcGetConnInfo(ahandle, &connInfo); - pHBRsp->ipList.index = 0; + pHBRsp->ipList.inUse = 0; pHBRsp->ipList.port = htons(tsMgmtShellPort); pHBRsp->ipList.numOfIps = 0; if (pSdbPublicIpList != NULL && pSdbIpList != NULL) { @@ -1035,7 +1035,7 @@ static int32_t mgmtProcessConnectMsg(void *pCont, int32_t contLen, void *thandle strcpy(pConnectRsp->serverVersion, version); pConnectRsp->writeAuth = pUser->writeAuth; pConnectRsp->superAuth = pUser->superAuth; - pConnectRsp->ipList.index = 0; + pConnectRsp->ipList.inUse = 0; pConnectRsp->ipList.port = htons(tsMgmtShellPort); pConnectRsp->ipList.numOfIps = 0; if (pSdbPublicIpList != NULL && pSdbIpList != NULL) { diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index af753eb289a35d64c18aa27bccbaa2f025adb748..33b6c06c514e67cac13809e36a2ae05eb331e670 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -24,6 +24,7 @@ #include "mgmtTable.h" void *tsUserSdb = NULL; +static int32_t tsUserUpdateSize = 0; void *(*mgmtUserActionFp[SDB_MAX_ACTION_TYPES])(void *row, char *str, int32_t size, int32_t *ssize); void *mgmtUserActionInsert(void *row, char *str, int32_t size, int32_t *ssize); @@ -59,7 +60,10 @@ int32_t mgmtInitUsers() { mgmtUserActionInit(); - tsUserSdb = sdbOpenTable(tsMaxUsers, sizeof(SUserObj), "user", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtUserAction); + SUserObj tObj; + tsUserUpdateSize = tObj.updateEnd - (int8_t *)&tObj; + + tsUserSdb = sdbOpenTable(tsMaxUsers, tsUserUpdateSize, "user", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtUserAction); if (tsUserSdb == NULL) { mError("failed to init user data"); return -1; @@ -265,12 +269,11 @@ void *mgmtUserActionUpdate(void *row, char *str, int32_t size, int32_t *ssize) { void *mgmtUserActionEncode(void *row, char *str, int32_t size, int32_t *ssize) { SUserObj *pUser = (SUserObj *) row; - int32_t tsize = pUser->updateEnd - (int8_t *) pUser; - if (size < tsize) { + if (size < tsUserUpdateSize) { *ssize = -1; } else { - memcpy(str, pUser, tsize); - *ssize = tsize; + memcpy(str, pUser, tsUserUpdateSize); + *ssize = tsUserUpdateSize; } return NULL; @@ -281,8 +284,7 @@ void *mgmtUserActionDecode(void *row, char *str, int32_t size, int32_t *ssize) { if (pUser == NULL) return NULL; memset(pUser, 0, sizeof(SUserObj)); - int32_t tsize = pUser->updateEnd - (int8_t *) pUser; - memcpy(pUser, str, tsize); + memcpy(pUser, str, tsUserUpdateSize); return (void *)pUser; } @@ -290,8 +292,7 @@ void *mgmtUserActionDecode(void *row, char *str, int32_t size, int32_t *ssize) { void *mgmtUserActionReset(void *row, char *str, int32_t size, int32_t *ssize) { SUserObj *pUser = (SUserObj *)row; - int32_t tsize = pUser->updateEnd - (int8_t *) pUser; - memcpy(pUser, str, tsize); + memcpy(pUser, str, tsUserUpdateSize); return NULL; }