Fix some review errors.

This commit is contained in:
xiao-77 2024-12-10 14:43:58 +08:00
parent 405d924a6f
commit 1455bb2a41
1 changed files with 45 additions and 10 deletions

View File

@ -335,7 +335,6 @@ bool tsExperimental = true;
int32_t tsMaxTsmaNum = 3; int32_t tsMaxTsmaNum = 3;
int32_t tsMaxTsmaCalcDelay = 600; int32_t tsMaxTsmaCalcDelay = 600;
int64_t tsmaDataDeleteMark = 1000 * 60 * 60 * 24; // in ms, default to 1d int64_t tsmaDataDeleteMark = 1000 * 60 * 60 * 24; // in ms, default to 1d
void* pTimezoneNameMap = NULL;
#define TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, pName) \ #define TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, pName) \
if ((pItem = cfgGetItem(pCfg, pName)) == NULL) { \ if ((pItem = cfgGetItem(pCfg, pName)) == NULL) { \
@ -1419,6 +1418,34 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
static int32_t taosSetSystemCfg(SConfig *pCfg) { static int32_t taosSetSystemCfg(SConfig *pCfg) {
SConfigItem *pItem = NULL; SConfigItem *pItem = NULL;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timezone");
if (0 == strlen(pItem->str)) {
uError("timezone is not set");
} else {
TAOS_CHECK_RETURN(osSetTimezone(pItem->str));
uDebug("timezone format changed from %s to %s", pItem->str, tsTimezoneStr);
}
TAOS_CHECK_RETURN(cfgSetItem(pCfg, "timezone", tsTimezoneStr, pItem->stype, true));
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "locale");
const char *locale = pItem->str;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "charset");
const char *charset = pItem->str;
int32_t code = taosSetSystemLocale(locale, charset);
if (TSDB_CODE_SUCCESS != code) {
uError("failed to set locale:%s, since: %s", locale, tstrerror(code));
char curLocale[TD_LOCALE_LEN] = {0};
char curCharset[TD_CHARSET_LEN] = {0};
taosGetSystemLocale(curLocale, curCharset);
if (0 != strlen(curLocale) && 0 != strlen(curCharset)) {
uInfo("current locale: %s, charset: %s", curLocale, curCharset);
}
}
osSetSystemLocale(locale, charset);
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableCoreFile"); TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableCoreFile");
tsEnableCoreFile = pItem->bval; tsEnableCoreFile = pItem->bval;
taosSetCoreDump(tsEnableCoreFile); taosSetCoreDump(tsEnableCoreFile);
@ -2012,6 +2039,7 @@ int32_t cfgDeserialize(SArray *array, char *buf, bool isGlobal) {
pItem->str = taosStrdup(pJson->valuestring); pItem->str = taosStrdup(pJson->valuestring);
if (pItem->str == NULL) { if (pItem->str == NULL) {
code = terrno; code = terrno;
goto _exit;
} }
break; break;
} }
@ -2043,7 +2071,8 @@ int32_t readCfgFile(const char *path, bool isGlobal) {
if (taosStatFile(filename, &fileSize, NULL, NULL) < 0) { if (taosStatFile(filename, &fileSize, NULL, NULL) < 0) {
if (terrno != ENOENT) { if (terrno != ENOENT) {
code = terrno; code = terrno;
uTrace("failed to stat file:%s , since %s", filename, tstrerror(code)); uError("failed to stat file:%s , since %s", filename, tstrerror(code));
TAOS_RETURN(TSDB_CODE_SUCCESS);
} }
uInfo("config file:%s does not exist", filename); uInfo("config file:%s does not exist", filename);
TAOS_RETURN(TSDB_CODE_SUCCESS); TAOS_RETURN(TSDB_CODE_SUCCESS);
@ -2407,9 +2436,6 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
if (strcasecmp("charset", name) == 0 || strcasecmp("timezone", name) == 0) {
goto _out;
}
cfgLock(pCfg); cfgLock(pCfg);
SConfigItem *pItem = cfgGetItem(pCfg, name); SConfigItem *pItem = cfgGetItem(pCfg, name);
@ -2501,15 +2527,18 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
case 'l': { case 'l': {
if (strcasecmp("locale", name) == 0) { if (strcasecmp("locale", name) == 0) {
SConfigItem *pLocaleItem = cfgGetItem(pCfg, "locale"); SConfigItem *pLocaleItem = cfgGetItem(pCfg, "locale");
if (pLocaleItem == NULL) { SConfigItem *pCharsetItem = cfgGetItem(pCfg, "charset");
uError("failed to get locale from cfg"); if (pLocaleItem == NULL || pCharsetItem == NULL) {
uError("failed to get locale or charset from cfg");
code = TSDB_CODE_CFG_NOT_FOUND; code = TSDB_CODE_CFG_NOT_FOUND;
goto _out; goto _out;
} }
const char *locale = pLocaleItem->str; const char *locale = pLocaleItem->str;
TAOS_CHECK_GOTO(taosSetSystemLocale(locale), &lino, _out); const char *charset = pCharsetItem->str;
uInfo("locale set to '%s'", locale); TAOS_CHECK_GOTO(taosSetSystemLocale(locale, charset), &lino, _out);
osSetSystemLocale(locale, charset);
uInfo("locale set to '%s', charset set to '%s'", locale, charset);
matched = true; matched = true;
} }
break; break;
@ -2584,7 +2613,13 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
break; break;
} }
case 't': { case 't': {
if (strcasecmp("tempDir", name) == 0) { if (strcasecmp("timezone", name) == 0) {
TAOS_CHECK_GOTO(osSetTimezone(pItem->str), &lino, _out);
uInfo("%s set from %s to %s", name, tsTimezoneStr, pItem->str);
TAOS_CHECK_GOTO(cfgSetItem(pCfg, "timezone", tsTimezoneStr, pItem->stype, false), &lino, _out);
matched = true;
} else if (strcasecmp("tempDir", name) == 0) {
uInfo("%s set from %s to %s", name, tsTempDir, pItem->str); uInfo("%s set from %s to %s", name, tsTempDir, pItem->str);
tstrncpy(tsTempDir, pItem->str, PATH_MAX); tstrncpy(tsTempDir, pItem->str, PATH_MAX);
TAOS_CHECK_GOTO(taosExpandDir(tsTempDir, tsTempDir, PATH_MAX), &lino, _out); TAOS_CHECK_GOTO(taosExpandDir(tsTempDir, tsTempDir, PATH_MAX), &lino, _out);