From 68af0bf32aa931bbe0233a69f6ffdfd68a7653ef Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 23 Nov 2021 20:01:05 +0800 Subject: [PATCH] TD-10430 minor changes for daemon module --- include/util/tconfig.h | 8 +++--- source/dnode/mgmt/daemon/src/daemon.c | 36 ++++++++++++++++----------- source/util/src/tconfig.c | 6 ++--- src/client/src/tscSystem.c | 2 +- src/kit/shell/src/shellMain.c | 2 +- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/include/util/tconfig.h b/include/util/tconfig.h index bc56d21b3a..15100423d5 100644 --- a/include/util/tconfig.h +++ b/include/util/tconfig.h @@ -82,10 +82,10 @@ extern SGlobalCfg tsGlobalConfig[]; extern int32_t tsGlobalConfigNum; extern char * tsCfgStatusStr[]; -void taosReadGlobalLogCfg(); -bool taosReadGlobalCfg(); -void taosPrintGlobalCfg(); -void taosDumpGlobalCfg(); +void taosReadGlobalLogCfg(); +int32_t taosReadGlobalCfg(); +void taosPrintGlobalCfg(); +void taosDumpGlobalCfg(); void taosInitConfigOption(SGlobalCfg cfg); SGlobalCfg *taosGetConfigOption(const char *option); diff --git a/source/dnode/mgmt/daemon/src/daemon.c b/source/dnode/mgmt/daemon/src/daemon.c index a57db1f778..4d1116466c 100644 --- a/source/dnode/mgmt/daemon/src/daemon.c +++ b/source/dnode/mgmt/daemon/src/daemon.c @@ -132,24 +132,30 @@ void dmnWaitSignal() { } } -void dmnInitOption(SDnodeOpt *pOpt) { - pOpt->sver = tsVersion; - pOpt->numOfCores = tsNumOfCores; - pOpt->statusInterval = tsStatusInterval; - pOpt->serverPort = tsServerPort; - tstrncpy(pOpt->localEp, tsLocalEp, TSDB_EP_LEN); - tstrncpy(pOpt->localFqdn, tsLocalEp, TSDB_FQDN_LEN); - tstrncpy(pOpt->timezone, tsLocalEp, TSDB_TIMEZONE_LEN); - tstrncpy(pOpt->locale, tsLocalEp, TSDB_LOCALE_LEN); - tstrncpy(pOpt->charset, tsLocalEp, TSDB_LOCALE_LEN); +void dmnInitOption(SDnodeOpt *pOption) { + pOption->sver = tsVersion; + pOption->numOfCores = tsNumOfCores; + pOption->numOfThreadsPerCore = tsNumOfThreadsPerCore; + pOption->ratioOfQueryCores = tsRatioOfQueryCores; + pOption->maxShellConns = tsMaxShellConns; + pOption->shellActivityTimer = tsShellActivityTimer; + pOption->statusInterval = tsStatusInterval; + pOption->serverPort = tsServerPort; + tstrncpy(pOption->dataDir, tsDataDir, TSDB_EP_LEN); + tstrncpy(pOption->localEp, tsLocalEp, TSDB_EP_LEN); + tstrncpy(pOption->localFqdn, tsLocalEp, TSDB_FQDN_LEN); + tstrncpy(pOption->firstEp, tsFirst, TSDB_FQDN_LEN); + tstrncpy(pOption->timezone, tsLocalEp, TSDB_TIMEZONE_LEN); + tstrncpy(pOption->locale, tsLocalEp, TSDB_LOCALE_LEN); + tstrncpy(pOption->charset, tsLocalEp, TSDB_LOCALE_LEN); } int dmnRunDnode() { - SDnodeOpt opt = {0}; - dmnInitOption(&opt); + SDnodeOpt option = {0}; + dmnInitOption(&option); - SDnode *pDnd = dndInit(&opt); - if (pDnd == NULL) { + SDnode *pDnode = dndInit(&option); + if (pDnode == NULL) { uInfo("Failed to start TDengine, please check the log at %s", tsLogDir); return -1; } @@ -158,7 +164,7 @@ int dmnRunDnode() { dmnWaitSignal(); uInfo("TDengine is shut down!"); - dndCleanup(pDnd); + dndCleanup(pDnode); taosCloseLog(); return 0; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index d249297e8b..8a6f389366 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -335,7 +335,7 @@ void taosReadGlobalLogCfg() { fclose(fp); } -bool taosReadGlobalCfg() { +int32_t taosReadGlobalCfg() { char * line, *option, *value, *value2, *value3; int olen, vlen, vlen2, vlen3; char fileName[PATH_MAX] = {0}; @@ -345,7 +345,7 @@ bool taosReadGlobalCfg() { if (fp == NULL) { fp = fopen(configDir, "r"); if (fp == NULL) { - return false; + return -1; } } @@ -393,7 +393,7 @@ bool taosReadGlobalCfg() { // taosSetAllDebugFlag(); // } - return true; + return 0; } void taosPrintGlobalCfg() { diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 0ca8e49fa7..badc97ba35 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -148,7 +148,7 @@ void taos_init_imp(void) { } taosReadGlobalCfg(); - if (taosCheckGlobalCfg()) { + if (taosCheckGlobalCfg() != 0) { tscInitRes = -1; return; } diff --git a/src/kit/shell/src/shellMain.c b/src/kit/shell/src/shellMain.c index 5c9dc0995d..29713686ea 100644 --- a/src/kit/shell/src/shellMain.c +++ b/src/kit/shell/src/shellMain.c @@ -106,7 +106,7 @@ int main(int argc, char* argv[]) { taosInitGlobalCfg(); taosReadGlobalLogCfg(); - if (!taosReadGlobalCfg()) { + if (taosReadGlobalCfg() ! =0) { printf("TDengine read global config failed"); exit(EXIT_FAILURE); }