From 156fa5d4c998e0b168f0b4152cb059bd436ebec2 Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 24 Feb 2020 21:31:03 +0800 Subject: [PATCH] compile for rpc rename index --- src/client/src/tscServer.c | 4 ++-- src/client/src/tscSql.c | 2 +- src/client/src/tscSystem.c | 2 +- src/mnode/src/mgmtShell.c | 4 ++-- src/mnode/src/mgmtUser.c | 19 ++++++++++--------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 8682672355..886716ebcf 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 cec84450ff..280b091cda 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 f805bfa4a8..6e4653c2d4 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 da1a1b8534..63e8a4e32f 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 af753eb289..33b6c06c51 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; }