diff --git a/include/common/tgrant.h b/include/common/tgrant.h index fc1e45fb2a..ae58ba88ad 100644 --- a/include/common/tgrant.h +++ b/include/common/tgrant.h @@ -28,12 +28,13 @@ extern "C" { #define GRANTS_COL_MAX_LEN 196 #endif -#define GRANT_HEART_BEAT_MIN 2 -#define GRANT_UNIQ_UNLIMITED (-1) -#define GRANT_ACTIVE_CODE "activeCode" -#define GRANT_FLAG_ALL (0x01) -#define GRANT_FLAG_AUDIT (0x02) -#define GRANT_FLAG_VIEW (0x04) +#define GRANT_HEART_BEAT_MIN 2 +#define GRANT_MAX_EXPIRE_SEC (31556995201) +#define GRANT_EXPIRE_UNLIMITED(v) ((v) == GRANT_MAX_EXPIRE_SEC) +#define GRANT_ACTIVE_CODE "activeCode" +#define GRANT_FLAG_ALL (0x01) +#define GRANT_FLAG_AUDIT (0x02) +#define GRANT_FLAG_VIEW (0x04) typedef enum { TSDB_GRANT_ALL, diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 0c446182a6..2da14c65d2 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -100,7 +100,7 @@ typedef struct { } SSyncMgmt; typedef struct { - int64_t expireTimeSec; + int64_t expireTimeMS; int64_t timeseriesAllowed; } SGrantInfo; diff --git a/source/dnode/mnode/impl/src/mndCluster.c b/source/dnode/mnode/impl/src/mndCluster.c index ca7544877c..a811a1ada0 100644 --- a/source/dnode/mnode/impl/src/mndCluster.c +++ b/source/dnode/mnode/impl/src/mndCluster.c @@ -312,17 +312,16 @@ static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock * char expireTime[25] = {0}; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); - if (tsExpireTime <= 0) { - if (tsExpireTime == GRANT_UNIQ_UNLIMITED) { - STR_WITH_MAXSIZE_TO_VARSTR(expireTime, "unlimited", pShow->pMeta->pSchemas[cols].bytes); - colDataSetVal(pColInfo, numOfRows, expireTime, false); - } else { - colDataSetNULL(pColInfo, numOfRows); - } + if (GRANT_EXPIRE_UNLIMITED(tsExpireTime / 1000)) { + STR_WITH_MAXSIZE_TO_VARSTR(expireTime, "unlimited", pShow->pMeta->pSchemas[cols].bytes); + colDataSetVal(pColInfo, numOfRows, expireTime, false); + } else if (tsExpireTime <= 0) { + colDataSetNULL(pColInfo, numOfRows); } else { char ts[20] = {0}; + time_t expireSec = tsExpireTime / 1000; struct tm ptm; - if (taosLocalTime(&tsExpireTime, &ptm, ts) != NULL) { + if (taosLocalTime(&expireSec, &ptm, ts) != NULL) { strftime(ts, 20, "%Y-%m-%d %H:%M:%S", &ptm); } else { ts[0] = 0; diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 7c8ef2f0b7..cad8c6d745 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -1028,11 +1028,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr } // grant info - pGrantInfo->expire_time = pMnode->grant.expireTimeSec == GRANT_UNIQ_UNLIMITED - ? GRANT_UNIQ_UNLIMITED - : (pMnode->grant.expireTimeSec - ms / 1000); + pGrantInfo->expire_time = (pMnode->grant.expireTimeMS - ms) / 1000; pGrantInfo->timeseries_total = pMnode->grant.timeseriesAllowed; - if (pMnode->grant.expireTimeSec == 0) { + if (pMnode->grant.expireTimeMS == 0) { pGrantInfo->expire_time = 0; pGrantInfo->timeseries_total = 0; }