fix: check taosSetSystemLocale errcode

This commit is contained in:
Shungang Li 2024-07-30 19:25:23 +08:00
parent 2c73757aa5
commit 965a4e56ea
2 changed files with 43 additions and 23 deletions

View File

@ -1212,7 +1212,17 @@ static int32_t taosSetSystemCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "charset"); TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "charset");
const char *charset = pItem->str; const char *charset = pItem->str;
(void)taosSetSystemLocale(locale, charset); // ignore this error temporarily int32_t code = taosSetSystemLocale(locale, charset);
if (TSDB_CODE_SUCCESS != code) {
uInfo("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); osSetSystemLocale(locale, charset);
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableCoreFile"); TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableCoreFile");
@ -1669,25 +1679,28 @@ static int32_t cfgInitWrapper(SConfig **pCfg) {
} }
TAOS_RETURN(TSDB_CODE_SUCCESS); TAOS_RETURN(TSDB_CODE_SUCCESS);
} }
int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs, int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs,
bool tsc) { bool tsc) {
if (tsCfg != NULL) TAOS_RETURN(TSDB_CODE_SUCCESS); if (tsCfg != NULL) TAOS_RETURN(TSDB_CODE_SUCCESS);
TAOS_CHECK_RETURN(cfgInitWrapper(&tsCfg)); int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = -1;
TAOS_CHECK_GOTO(cfgInitWrapper(&tsCfg), &lino, _exit);
if (tsc) { if (tsc) {
TAOS_CHECK_RETURN(taosAddClientCfg(tsCfg)); TAOS_CHECK_GOTO(taosAddClientCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosAddClientLogCfg(tsCfg)); TAOS_CHECK_GOTO(taosAddClientLogCfg(tsCfg), &lino, _exit);
} else { } else {
TAOS_CHECK_RETURN(taosAddClientCfg(tsCfg)); TAOS_CHECK_GOTO(taosAddClientCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosAddServerCfg(tsCfg)); TAOS_CHECK_GOTO(taosAddServerCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosAddClientLogCfg(tsCfg)); TAOS_CHECK_GOTO(taosAddClientLogCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosAddServerLogCfg(tsCfg)); TAOS_CHECK_GOTO(taosAddServerLogCfg(tsCfg), &lino, _exit);
} }
TAOS_CHECK_RETURN(taosAddSystemCfg(tsCfg)); TAOS_CHECK_GOTO(taosAddSystemCfg(tsCfg), &lino, _exit);
int32_t code = TSDB_CODE_SUCCESS;
if ((code = taosLoadCfg(tsCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) { if ((code = taosLoadCfg(tsCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) {
uError("failed to load cfg since %s", tstrerror(code)); uError("failed to load cfg since %s", tstrerror(code));
cfgCleanup(tsCfg); cfgCleanup(tsCfg);
@ -1703,31 +1716,38 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
} }
if (tsc) { if (tsc) {
TAOS_CHECK_RETURN(taosSetClientCfg(tsCfg)); TAOS_CHECK_GOTO(taosSetClientCfg(tsCfg), &lino, _exit);
} else { } else {
TAOS_CHECK_RETURN(taosSetClientCfg(tsCfg)); TAOS_CHECK_GOTO(taosSetClientCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosUpdateServerCfg(tsCfg)); TAOS_CHECK_GOTO(taosUpdateServerCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosSetServerCfg(tsCfg)); TAOS_CHECK_GOTO(taosSetServerCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosSetReleaseCfg(tsCfg)); TAOS_CHECK_GOTO(taosSetReleaseCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosSetTfsCfg(tsCfg)); TAOS_CHECK_GOTO(taosSetTfsCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosSetS3Cfg(tsCfg)); TAOS_CHECK_GOTO(taosSetS3Cfg(tsCfg), &lino, _exit);
} }
TAOS_CHECK_RETURN(taosSetSystemCfg(tsCfg)); TAOS_CHECK_GOTO(taosSetSystemCfg(tsCfg), &lino, _exit);
TAOS_CHECK_RETURN(taosSetFileHandlesLimit()); TAOS_CHECK_GOTO(taosSetFileHandlesLimit(), &lino, _exit);
SConfigItem *pItem = cfgGetItem(tsCfg, "debugFlag"); SConfigItem *pItem = cfgGetItem(tsCfg, "debugFlag");
if (NULL == pItem) { if (NULL == pItem) {
uError("debugFlag not found in cfg"); uError("debugFlag not found in cfg");
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
} }
TAOS_CHECK_RETURN(taosSetAllDebugFlag(tsCfg, pItem->i32)); TAOS_CHECK_GOTO(taosSetAllDebugFlag(tsCfg, pItem->i32), &lino, _exit);
cfgDumpCfg(tsCfg, tsc, false); cfgDumpCfg(tsCfg, tsc, false);
TAOS_CHECK_RETURN(taosCheckGlobalCfg()); TAOS_CHECK_GOTO(taosCheckGlobalCfg(), &lino, _exit);
TAOS_RETURN(TSDB_CODE_SUCCESS); _exit:
if (TSDB_CODE_SUCCESS != code) {
cfgCleanup(tsCfg);
tsCfg = NULL;
uError("failed to init cfg at %d since %s", lino, tstrerror(code));
}
TAOS_RETURN(code);
} }
void taosCleanupCfg() { void taosCleanupCfg() {

View File

@ -75,7 +75,7 @@ char *taosCharsetReplace(char *charsetstr) {
* *
* In case that the setLocale failed to be executed, the right charset needs to be set. * In case that the setLocale failed to be executed, the right charset needs to be set.
*/ */
int32_t taosSetSystemLocale(const char *inLocale, const char *inCharSet) {\ int32_t taosSetSystemLocale(const char *inLocale, const char *inCharSet) {
if (!taosValidateEncodec(inCharSet)) { if (!taosValidateEncodec(inCharSet)) {
return terrno; return terrno;
} }