Merge pull request #2739 from taosdata/bugfix/td-900

fix td-900: support both config dir & file
This commit is contained in:
Shengliang Guan 2020-07-22 14:59:48 +08:00 committed by GitHub
commit 0fb871cc97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 22 deletions

View File

@ -308,11 +308,21 @@ bool taosReadGlobalCfg() {
sprintf(fileName, "%s/taos.cfg", configDir);
FILE* fp = fopen(fileName, "r");
if (fp == NULL) {
struct stat s;
if (stat(configDir, &s) != 0 || (!S_ISREG(s.st_mode) && !S_ISLNK(s.st_mode))) {
//return true to follow behavior before file support
return true;
}
fp = fopen(configDir, "r");
if (fp == NULL) {
return false;
}
}
size_t len = 1024;
line = calloc(1, len);
if (fp != NULL) {
while (!feof(fp)) {
memset(line, 0, len);
@ -338,7 +348,6 @@ bool taosReadGlobalCfg() {
}
fclose(fp);
}
tfree(line);