From 2fcf9dc63830cee1b68d8ee1a59291e34f1938cd Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 24 Feb 2022 14:31:36 +0800 Subject: [PATCH] charset --- include/dnode/mgmt/dnode.h | 5 ----- include/dnode/mnode/mnode.h | 5 ----- source/dnode/mgmt/daemon/src/dmnCfg.c | 5 ----- source/dnode/mgmt/impl/src/dndEnv.c | 3 --- source/dnode/mgmt/impl/src/dndMgmt.c | 6 +++--- source/dnode/mgmt/impl/src/dndMnode.c | 5 ----- source/dnode/mnode/impl/inc/mndInt.h | 1 + source/dnode/mnode/impl/src/mndDnode.c | 18 +++++++++--------- source/dnode/mnode/impl/src/mndTelem.c | 10 +++------- source/dnode/mnode/impl/src/mnode.c | 15 --------------- 10 files changed, 16 insertions(+), 57 deletions(-) diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h index d630fd0b1a..a5882c49e2 100644 --- a/include/dnode/mgmt/dnode.h +++ b/include/dnode/mgmt/dnode.h @@ -34,11 +34,6 @@ typedef struct { bool printAuth; int32_t rpcTimer; int32_t rpcMaxTime; - char timezone[TD_TIMEZONE_LEN]; - char locale[TD_LOCALE_LEN]; - char charset[TD_LOCALE_LEN]; - char buildinfo[64]; - char gitinfo[48]; } SDnodeEnvCfg; /** diff --git a/include/dnode/mnode/mnode.h b/include/dnode/mnode/mnode.h index 01855f6d92..a876827239 100644 --- a/include/dnode/mnode/mnode.h +++ b/include/dnode/mnode/mnode.h @@ -50,11 +50,6 @@ typedef struct SMnodeCfg { bool printAuth; int32_t statusInterval; int32_t shellActivityTimer; - char *timezone; - char *locale; - char *charset; - char *buildinfo; - char *gitinfo; } SMnodeCfg; typedef struct { diff --git a/source/dnode/mgmt/daemon/src/dmnCfg.c b/source/dnode/mgmt/daemon/src/dmnCfg.c index 65c3e67d97..5713df80c5 100644 --- a/source/dnode/mgmt/daemon/src/dmnCfg.c +++ b/source/dnode/mgmt/daemon/src/dmnCfg.c @@ -184,11 +184,6 @@ SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg) { const char *vstr = cfgGetItem(pCfg, "version")->str; envCfg.sver = 30000000; - tstrncpy(envCfg.buildinfo, cfgGetItem(pCfg, "buildinfo")->str, sizeof(envCfg.buildinfo)); - tstrncpy(envCfg.gitinfo, cfgGetItem(pCfg, "gitinfo")->str, sizeof(envCfg.gitinfo)); - tstrncpy(envCfg.timezone, cfgGetItem(pCfg, "timezone")->str, sizeof(envCfg.timezone)); - tstrncpy(envCfg.locale, cfgGetItem(pCfg, "locale")->str, sizeof(envCfg.locale)); - tstrncpy(envCfg.charset, cfgGetItem(pCfg, "charset")->str, sizeof(envCfg.charset)); envCfg.numOfCores = cfgGetItem(pCfg, "numOfCores")->i32; envCfg.numOfCommitThreads = (uint16_t)cfgGetItem(pCfg, "numOfCommitThreads")->i32; envCfg.enableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; diff --git a/source/dnode/mgmt/impl/src/dndEnv.c b/source/dnode/mgmt/impl/src/dndEnv.c index b8f249f838..7c45474be4 100644 --- a/source/dnode/mgmt/impl/src/dndEnv.c +++ b/source/dnode/mgmt/impl/src/dndEnv.c @@ -285,9 +285,6 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) { SVnodeOpt vnodeOpt = { .sver = pCfg->sver, - .timezone = pCfg->timezone, - .locale = pCfg->locale, - .charset = pCfg->charset, .nthreads = pCfg->numOfCommitThreads, .putReqToVQueryQFp = dndPutReqToVQueryQ, .sendReqToDnodeFp = dndSendReqToDnode diff --git a/source/dnode/mgmt/impl/src/dndMgmt.c b/source/dnode/mgmt/impl/src/dndMgmt.c index b7f42fb465..6ba6d9ce1c 100644 --- a/source/dnode/mgmt/impl/src/dndMgmt.c +++ b/source/dnode/mgmt/impl/src/dndMgmt.c @@ -371,9 +371,9 @@ void dndSendStatusReq(SDnode *pDnode) { req.clusterCfg.checkTime = 0; char timestr[32] = "1970-01-01 00:00:00.00"; (void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0); - memcpy(req.clusterCfg.timezone, pDnode->env.timezone, TD_TIMEZONE_LEN); - memcpy(req.clusterCfg.locale, pDnode->env.locale, TD_LOCALE_LEN); - memcpy(req.clusterCfg.charset, pDnode->env.charset, TD_LOCALE_LEN); + memcpy(req.clusterCfg.timezone, osTimezone(), TD_TIMEZONE_LEN); + memcpy(req.clusterCfg.locale, osLocale(), TD_LOCALE_LEN); + memcpy(req.clusterCfg.charset, osCharset(), TD_LOCALE_LEN); taosRUnLockLatch(&pMgmt->latch); req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad)); diff --git a/source/dnode/mgmt/impl/src/dndMnode.c b/source/dnode/mgmt/impl/src/dndMnode.c index c6db75c057..3117a85561 100644 --- a/source/dnode/mgmt/impl/src/dndMnode.c +++ b/source/dnode/mgmt/impl/src/dndMnode.c @@ -277,11 +277,6 @@ static void dndInitMnodeOption(SDnode *pDnode, SMnodeOpt *pOption) { pOption->cfg.enableTelem = pDnode->env.enableTelem; pOption->cfg.statusInterval = pDnode->cfg.statusInterval; pOption->cfg.shellActivityTimer = pDnode->cfg.shellActivityTimer; - pOption->cfg.timezone = pDnode->env.timezone; - pOption->cfg.charset = pDnode->env.charset; - pOption->cfg.locale = pDnode->env.locale; - pOption->cfg.gitinfo = pDnode->env.gitinfo; - pOption->cfg.buildinfo = pDnode->env.buildinfo; } static void dndBuildMnodeDeployOption(SDnode *pDnode, SMnodeOpt *pOption) { diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 5c32da966b..74ae159d9d 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -24,6 +24,7 @@ #include "tqueue.h" #include "ttime.h" #include "wal.h" +#include "version.h" #ifdef __cplusplus extern "C" { diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 39ea4b482c..b520acf2d2 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -277,19 +277,19 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) { return DND_REASON_STATUS_INTERVAL_NOT_MATCH; } - if ((0 != strcasecmp(pCfg->timezone, pMnode->cfg.timezone)) && (pMnode->checkTime != pCfg->checkTime)) { - mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, pMnode->cfg.timezone, + if ((0 != strcasecmp(pCfg->timezone, osTimezone())) && (pMnode->checkTime != pCfg->checkTime)) { + mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, osTimezone(), pCfg->checkTime, pMnode->checkTime); return DND_REASON_TIME_ZONE_NOT_MATCH; } - if (0 != strcasecmp(pCfg->locale, pMnode->cfg.locale)) { - mError("locale [%s - %s] cfg inconsistent", pCfg->locale, pMnode->cfg.locale); + if (0 != strcasecmp(pCfg->locale, osLocale())) { + mError("locale [%s - %s] cfg inconsistent", pCfg->locale, osLocale()); return DND_REASON_LOCALE_NOT_MATCH; } - if (0 != strcasecmp(pCfg->charset, pMnode->cfg.charset)) { - mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, pMnode->cfg.charset); + if (0 != strcasecmp(pCfg->charset, osCharset())) { + mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, osCharset()); return DND_REASON_CHARSET_NOT_MATCH; } @@ -670,15 +670,15 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data, numOfRows++; cfgOpts[numOfRows] = "timezone"; - snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.timezone); + snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osTimezone()); numOfRows++; cfgOpts[numOfRows] = "locale"; - snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.locale); + snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osLocale()); numOfRows++; cfgOpts[numOfRows] = "charset"; - snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.charset); + snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osCharset()); numOfRows++; for (int32_t i = 0; i < numOfRows; i++) { diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c index 5292dd0a41..ced1be687d 100644 --- a/source/dnode/mnode/impl/src/mndTelem.c +++ b/source/dnode/mnode/impl/src/mndTelem.c @@ -138,13 +138,9 @@ static void mndAddMemoryInfo(SMnode* pMnode, SBufferWriter* bw) { static void mndAddVersionInfo(SMnode* pMnode, SBufferWriter* bw) { STelemMgmt* pMgmt = &pMnode->telemMgmt; - - char vstr[32] = {0}; - taosVersionIntToStr(pMnode->cfg.sver, vstr, 32); - - mndAddStringField(bw, "version", vstr); - mndAddStringField(bw, "buildInfo", pMnode->cfg.buildinfo); - mndAddStringField(bw, "gitInfo", pMnode->cfg.gitinfo); + mndAddStringField(bw, "version", version); + mndAddStringField(bw, "buildInfo", buildinfo); + mndAddStringField(bw, "gitInfo", gitinfo); mndAddStringField(bw, "email", pMgmt->email); } diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 299e66a7c0..f5acc897e7 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -294,11 +294,6 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) { pMnode->cfg.enableTelem = pOption->cfg.enableTelem; pMnode->cfg.statusInterval = pOption->cfg.statusInterval; pMnode->cfg.shellActivityTimer = pOption->cfg.shellActivityTimer; - pMnode->cfg.timezone = strdup(pOption->cfg.timezone); - pMnode->cfg.locale = strdup(pOption->cfg.locale); - pMnode->cfg.charset = strdup(pOption->cfg.charset); - pMnode->cfg.gitinfo = strdup(pOption->cfg.gitinfo); - pMnode->cfg.buildinfo = strdup(pOption->cfg.buildinfo); if (pMnode->sendReqToDnodeFp == NULL || pMnode->sendReqToMnodeFp == NULL || pMnode->sendRedirectRspFp == NULL || pMnode->putReqToMWriteQFp == NULL || pMnode->dnodeId < 0 || pMnode->clusterId < 0 || @@ -307,11 +302,6 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) { return -1; } - if (pMnode->cfg.timezone == NULL || pMnode->cfg.locale == NULL || pMnode->cfg.charset == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - return 0; } @@ -381,11 +371,6 @@ void mndClose(SMnode *pMnode) { mDebug("start to close mnode"); mndCleanupSteps(pMnode, -1); tfree(pMnode->path); - tfree(pMnode->cfg.charset); - tfree(pMnode->cfg.locale); - tfree(pMnode->cfg.timezone); - tfree(pMnode->cfg.gitinfo); - tfree(pMnode->cfg.buildinfo); tfree(pMnode); mDebug("mnode is closed"); }