From 9c468129d20ef431957bc366c0328739f0daa940 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Tue, 29 Oct 2019 17:26:59 +0800 Subject: [PATCH] fix the bug that the setLocale function return wrong value to cause both the TDengine and Shell fail to launch.#494 #478 --- src/util/src/tglobalcfg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index b3487a7971..7bdd4df7e5 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -831,6 +831,12 @@ void tsSetAllDebugFlag() { pPrint("all debug flag are set to %d", debugFlag); } +/** + * In some Linux systems, setLocale(LC_CTYPE, "") may return NULL, in which case the launch of + * both the TDengine Server and the Client may be interrupted. + * + * In case that the setLocale failed to be executed, the right charset needs to be set. + */ void tsSetLocale() { char msgLocale[] = "Invalid locale:%s, please set the valid locale in config file"; char msgCharset[] = "Invalid charset:%s, please set the valid charset in config file"; @@ -838,11 +844,10 @@ void tsSetLocale() { char *locale = setlocale(LC_CTYPE, tsLocale); - /* default locale or user specified locale is not valid, abort launch */ + // default locale or user specified locale is not valid, abort launch if (locale == NULL) { printf(msgLocale, tsLocale); pPrint(msgLocale, tsLocale); - exit(-1); } if (strlen(tsCharset) == 0) { -- GitLab