From 92171e080ed7c44d972cc220111fa043459040cf Mon Sep 17 00:00:00 2001 From: xsren <285808407@qq.com> Date: Fri, 13 Sep 2024 15:20:23 +0800 Subject: [PATCH 1/4] ostime and ossocket --- include/os/osTimezone.h | 2 +- include/util/taoserror.h | 1 + source/common/src/tglobal.c | 5 +- source/os/src/osEnv.c | 5 +- source/os/src/osRand.c | 2 +- source/os/src/osTimezone.c | 96 ++++++++++++++++++------------------- 6 files changed, 59 insertions(+), 52 deletions(-) diff --git a/include/os/osTimezone.h b/include/os/osTimezone.h index fab42e8e11..2a8d5a442d 100644 --- a/include/os/osTimezone.h +++ b/include/os/osTimezone.h @@ -54,7 +54,7 @@ enum TdTimezone { TdEastZone12 }; -void taosGetSystemTimezone(char *outTimezone, enum TdTimezone *tsTimezone); +int32_t taosGetSystemTimezone(char *outTimezone, enum TdTimezone *tsTimezone); int32_t taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight, enum TdTimezone *tsTimezone); #ifdef __cplusplus diff --git a/include/util/taoserror.h b/include/util/taoserror.h index eb329192a2..17bb6d373c 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -157,6 +157,7 @@ int32_t taosGetErrSize(); #define TSDB_CODE_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0138) #define TSDB_CODE_SOCKET_ERROR TAOS_DEF_ERROR_CODE(0, 0x0139) #define TSDB_CODE_UNSUPPORT_OS TAOS_DEF_ERROR_CODE(0, 0x013A) +#define TSDB_CODE_TIME_ERROR TAOS_DEF_ERROR_CODE(0, 0x013B) //client #define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 5b67e1267b..b852a096f8 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1696,7 +1696,10 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char * SArray *pArgs) { int32_t code = TSDB_CODE_SUCCESS; - if (tsCfg == NULL) osDefaultInit(); + if (tsCfg == NULL) code = osDefaultInit(); + if (code != 0) { + (void)printf("failed to init os since %s\n", tstrerror(code)); + } SConfig *pCfg = NULL; TAOS_CHECK_RETURN(cfgInit(&pCfg)); diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index c0273e4a6f..f2c90e778d 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -50,7 +50,10 @@ int32_t osDefaultInit() { taosSeedRand(taosSafeRand()); taosGetSystemLocale(tsLocale, tsCharset); - taosGetSystemTimezone(tsTimezoneStr, &tsTimezone); + code = taosGetSystemTimezone(tsTimezoneStr, &tsTimezone); + if(code != 0) { + return code; + } if (strlen(tsTimezoneStr) > 0) { // ignore empty timezone if ((code = taosSetSystemTimezone(tsTimezoneStr, tsTimezoneStr, &tsDaylight, &tsTimezone)) != TSDB_CODE_SUCCESS) return code; diff --git a/source/os/src/osRand.c b/source/os/src/osRand.c index da4e8dfb9d..b99017782b 100644 --- a/source/os/src/osRand.c +++ b/source/os/src/osRand.c @@ -69,7 +69,7 @@ uint32_t taosSafeRand(void) { if (len < 0) { seed = (int)taosGetTimestampSec(); } - (void)taosCloseFile(&pFile); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); } return (uint32_t)seed; diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index 8fdd296655..1d8a552862 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -811,7 +811,11 @@ int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, i #elif defined(_TD_DARWIN_64) - setenv("TZ", buf, 1); + code = setenv("TZ", buf, 1); + if (-1 == code) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } tzset(); int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR); *tsTimezone = tz; @@ -839,13 +843,17 @@ int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, i return code; } -void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { +int32_t taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { + int32_t code = 0; #ifdef WINDOWS char value[100]; char keyPath[100]; DWORD bufferSize = sizeof(value); - RegGetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "TimeZoneKeyName", + LONG result = RegGetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "TimeZoneKeyName", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); + if (result != ERROR_SUCCESS) { + return TAOS_SYSTEM_WINAPI_ERROR(result); + } strcpy(outTimezoneStr, "not configured"); *tsTimezone = 0; if (bufferSize > 0) { @@ -854,7 +862,10 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { strcpy(outTimezoneStr, win_tz[i][1]); bufferSize = sizeof(value); sprintf(keyPath, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%s", value); - RegGetValue(HKEY_LOCAL_MACHINE, keyPath, "Display", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); + result = RegGetValue(HKEY_LOCAL_MACHINE, keyPath, "Display", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); + if (result != ERROR_SUCCESS) { + return TAOS_SYSTEM_WINAPI_ERROR(result); + } if (bufferSize > 0) { // value[4] = (value[4] == '+' ? '-' : '+'); sprintf(outTimezoneStr, "%s (UTC, %c%c%c%c%c)", outTimezoneStr, value[4], value[5], value[6], value[8], @@ -865,6 +876,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { } } } + return 0; #elif defined(_TD_DARWIN_64) char buf[4096] = {0}; char *tz = NULL; @@ -883,21 +895,11 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { } tz = zi + strlen("zoneinfo") + 1; - // for (int i = n - 1; i >= 0; --i) { - // if (buf[i] == '/') { - // if (tz) { - // tz = buf + i + 1; - // break; - // } - // tz = buf + i + 1; - // } - // } - // if (!tz || 0 == strchr(tz, '/')) { - // printf("parsing /etc/localtime failed\n"); - // return; - // } - - setenv("TZ", tz, 1); + code = setenv("TZ", tz, 1); + if (-1 == code) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } tzset(); } @@ -908,7 +910,9 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; - taosLocalTime(&tx1, &tm1, NULL); + if (taosLocalTime(&tx1, &tm1, NULL) == NULL) { + return TSDB_CODE_TIME_ERROR; + } daylight = tm1.tm_isdst; isdst_now = tm1.tm_isdst; @@ -920,6 +924,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0], -timezone / 3600); + return 0; #else char buf[4096] = {0}; @@ -927,8 +932,6 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { { int n = readlink("/etc/localtime", buf, sizeof(buf)-1); if (n < 0) { - (void)printf("read /etc/localtime error, reason:%s\n", strerror(errno)); - if (taosCheckExistFile("/etc/timezone")) { /* * NOTE: do not remove it. @@ -937,7 +940,9 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; - (void)taosLocalTime(&tx1, &tm1, NULL); + if(taosLocalTime(&tx1, &tm1, NULL) == NULL) { + return TSDB_CODE_TIME_ERROR; + } /* load time zone string from /etc/timezone */ // FILE *f = fopen("/etc/timezone", "r"); errno = 0; @@ -946,12 +951,11 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { if (pFile != NULL) { int len = taosReadFile(pFile, buf, 64); if (len < 0) { - (void)taosCloseFile(&pFile); - (void)printf("read /etc/timezone error, reason:%s\n", strerror(errno)); - return; + TAOS_UNUSED(taosCloseFile(&pFile)); + return TSDB_CODE_TIME_ERROR; } - (void)taosCloseFile(&pFile); + TAOS_UNUSED(taosCloseFile(&pFile)); buf[sizeof(buf) - 1] = 0; char *lineEnd = strstr(buf, "\n"); @@ -961,7 +965,11 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { // for CentOS system, /etc/timezone does not exist. Ignore the TZ environment variables if (strlen(buf) > 0) { - (void)setenv("TZ", buf, 1); + code = setenv("TZ", buf, 1); + if (-1 == code) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } } } // get and set default timezone @@ -986,34 +994,23 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { (void)snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); } else { - (void)printf("There is not /etc/timezone.\n"); + return TSDB_CODE_TIME_ERROR; } - return; + return 0; } buf[n] = '\0'; char *zi = strstr(buf, "zoneinfo"); if (!zi) { - (void)printf("parsing /etc/localtime failed\n"); - return; + return TSDB_CODE_TIME_ERROR; } tz = zi + strlen("zoneinfo") + 1; - // for (int i = n - 1; i >= 0; --i) { - // if (buf[i] == '/') { - // if (tz) { - // tz = buf + i + 1; - // break; - // } - // tz = buf + i + 1; - // } - // } - // if (!tz || 0 == strchr(tz, '/')) { - // printf("parsing /etc/localtime failed"); - // return; - // } - - (void)setenv("TZ", tz, 1); + code = setenv("TZ", tz, 1); + if (-1 == code) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } tzset(); } @@ -1024,7 +1021,9 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; - (void)taosLocalTime(&tx1, &tm1, NULL); + if(taosLocalTime(&tx1, &tm1, NULL) == NULL) { + return TSDB_CODE_TIME_ERROR; + } isdst_now = tm1.tm_isdst; /* @@ -1035,5 +1034,6 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ (void)snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0], -timezone / 3600); + return 0; #endif } From 661a170a9b988a86b4606abb01286add287b67bc Mon Sep 17 00:00:00 2001 From: xsren <285808407@qq.com> Date: Fri, 13 Sep 2024 15:26:14 +0800 Subject: [PATCH 2/4] osTimer --- source/os/src/osSocket.c | 29 +++++++++++++---------------- source/os/src/osTimer.c | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 4d650715f9..851615fb7f 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -120,7 +120,12 @@ int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t int32_t taosCloseSocketNoCheck1(SocketFd fd) { #ifdef WINDOWS - return closesocket(fd); + int ret = closesocket(fd); + if (ret == SOCKET_ERROR) { + int errorCode = WSAGetLastError(); + return terrno = TAOS_SYSTEM_WINSOCKET_ERROR(errorCode); + } + return 0; #else int32_t code = close(fd); if (-1 == code) { @@ -770,10 +775,7 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) { TdSocketPtr pSocket = (TdSocketPtr)taosMemoryMalloc(sizeof(TdSocket)); if (pSocket == NULL) { - code = terrno; - (void)taosCloseSocketNoCheck1(fd); - terrno = code; - + TAOS_SKIP_ERROR(taosCloseSocketNoCheck1(fd)); return false; } pSocket->refId = 0; @@ -782,22 +784,18 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) { /* set REUSEADDR option, so the portnumber can be re-used */ reuse = 1; if (taosSetSockOpt(pSocket, SOL_SOCKET, SO_REUSEADDR, (void *)&reuse, sizeof(reuse)) < 0) { - code = terrno; - (void)taosCloseSocket(&pSocket); - terrno = code; - + TAOS_SKIP_ERROR(taosCloseSocket(&pSocket)); return false; } /* bind socket to server address */ if (-1 == bind(pSocket->fd, (struct sockaddr *)&serverAdd, sizeof(serverAdd))) { - code = TAOS_SYSTEM_ERROR(errno); - (void)taosCloseSocket(&pSocket); - terrno = code; + terrno = TAOS_SYSTEM_ERROR(errno); + TAOS_SKIP_ERROR(taosCloseSocket(&pSocket)); return false; } - (void)taosCloseSocket(&pSocket); + TAOS_SKIP_ERROR(taosCloseSocket(&pSocket)); return true; } @@ -1160,9 +1158,8 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) { #else // Linux like systems uint32_t conn_timeout_ms = timeout; if (-1 == setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) { - int32_t code = TAOS_SYSTEM_ERROR(errno); - (void)taosCloseSocketNoCheck1(fd); - terrno = code; + terrno = TAOS_SYSTEM_ERROR(errno); + TAOS_SKIP_ERROR(taosCloseSocketNoCheck1(fd)); return -1; } #endif diff --git a/source/os/src/osTimer.c b/source/os/src/osTimer.c index 6e5d9844a9..fe3a0dcf95 100644 --- a/source/os/src/osTimer.c +++ b/source/os/src/osTimer.c @@ -80,7 +80,7 @@ void taos_block_sigalrm(void) { static void taosDeleteTimer(void *tharg) { timer_t *pTimer = tharg; - (void)timer_delete(*pTimer); + TAOS_SKIP_ERROR(timer_delete(*pTimer)); } static TdThread timerThread; From a91085eef6afc78cba8bdae69dc10a92919404b9 Mon Sep 17 00:00:00 2001 From: xsren <285808407@qq.com> Date: Fri, 13 Sep 2024 16:14:40 +0800 Subject: [PATCH 3/4] fix: void --- source/libs/function/src/tudf.c | 5 ++++- source/os/src/osDir.c | 6 +++--- source/os/src/osSleep.c | 15 ++++++++++----- source/os/src/osSysinfo.c | 27 ++++++++++++++------------- source/util/src/tlog.c | 5 ++++- 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index d0b3b191ad..0510b6cff5 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -127,7 +127,10 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) { snprintf(dnodeIdEnvItem, 32, "%s=%d", "DNODE_ID", pData->dnodeId); float numCpuCores = 4; - taosGetCpuCores(&numCpuCores, false); + int32_t code = taosGetCpuCores(&numCpuCores, false); + if(code != 0) { + fnError("failed to get cpu cores, code:%d", code); + } numCpuCores = TMAX(numCpuCores, 2); snprintf(thrdPoolSizeEnvItem, 32, "%s=%d", "UV_THREADPOOL_SIZE", (int)numCpuCores * 2); diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index e06c1a6aac..04747cacd4 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -109,8 +109,8 @@ void taosRemoveDir(const char *dirname) { } } - (void)taosCloseDir(&pDir); - (void)rmdir(dirname); + TAOS_UNUSED(taosCloseDir(&pDir)); + TAOS_UNUSED(rmdir(dirname)); // printf("dir:%s is removed\n", dirname); return; @@ -374,7 +374,7 @@ int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen) { bool taosIsDir(const char *dirname) { TdDirPtr pDir = taosOpenDir(dirname); if (pDir != NULL) { - (void)taosCloseDir(&pDir); + TAOS_SKIP_ERROR(taosCloseDir(&pDir)); return true; } return false; diff --git a/source/os/src/osSleep.c b/source/os/src/osSleep.c index f72805b15d..67a621e8b7 100644 --- a/source/os/src/osSleep.c +++ b/source/os/src/osSleep.c @@ -37,7 +37,7 @@ void taosMsleep(int32_t ms) { #ifdef WINDOWS Sleep(ms); #else - (void)usleep(ms * 1000); + TAOS_SKIP_ERROR(usleep(ms * 1000)); #endif } @@ -49,10 +49,15 @@ void taosUsleep(int32_t us) { interval.QuadPart = (10 * us); timer = CreateWaitableTimer(NULL, TRUE, NULL); - SetWaitableTimer(timer, &interval, 0, NULL, NULL, 0); - WaitForSingleObject(timer, INFINITE); - CloseHandle(timer); + if (timer == NULL) { + return; + } + if (!SetWaitableTimer(timer, &interval, 0, NULL, NULL, 0)) { + return; + } + TAOS_SKIP_ERROR(WaitForSingleObject(timer, INFINITE)); + TAOS_SKIP_ERROR(CloseHandle(timer)); #else - (void)usleep(us); + TAOS_SKIP_ERROR(usleep(us)); #endif } diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 36b1d7b60d..fc6296bc04 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -191,10 +191,11 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) { &cpuInfo->si, &cpuInfo->st, &cpuInfo->guest, &cpuInfo->guest_nice); if (EOF == code) { terrno = TAOS_SYSTEM_ERROR(errno); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); return terrno; } - (void)taosCloseFile(&pFile); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); #endif return 0; @@ -263,9 +264,9 @@ bool taosCheckSystemIsLittleEnd() { void taosGetSystemInfo() { #ifdef WINDOWS - taosGetCpuCores(&tsNumOfCores, false); - taosGetTotalMemory(&tsTotalMemoryKB); - taosGetCpuUsage(NULL, NULL); + TAOS_SKIP_ERROR(taosGetCpuCores(&tsNumOfCores, false)); + TAOS_SKIP_ERROR(taosGetTotalMemory(&tsTotalMemoryKB)); + TAOS_SKIP_ERROR(taosGetCpuUsage(NULL, NULL)); #elif defined(_TD_DARWIN_64) long physical_pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGESIZE); @@ -274,10 +275,10 @@ void taosGetSystemInfo() { tsNumOfCores = sysconf(_SC_NPROCESSORS_ONLN); #else taosGetProcIOnfos(); - (void)taosGetCpuCores(&tsNumOfCores, false); - (void)taosGetTotalMemory(&tsTotalMemoryKB); - (void)taosGetCpuUsage(NULL, NULL); - (void)taosGetCpuInstructions(&tsSSE42Supported, &tsAVXSupported, &tsAVX2Supported, &tsFMASupported, &tsAVX512Supported); + TAOS_SKIP_ERROR(taosGetCpuCores(&tsNumOfCores, false)); + TAOS_SKIP_ERROR(taosGetTotalMemory(&tsTotalMemoryKB)); + TAOS_SKIP_ERROR(taosGetCpuUsage(NULL, NULL)); + TAOS_SKIP_ERROR(taosGetCpuInstructions(&tsSSE42Supported, &tsAVXSupported, &tsAVX2Supported, &tsFMASupported, &tsAVX512Supported)); #endif } @@ -313,11 +314,11 @@ int32_t taosGetEmail(char *email, int32_t maxLen) { if (taosReadFile(pFile, (void *)email, maxLen) < 0) { int32_t code = terrno; - (void)taosCloseFile(&pFile); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); return code; } - (void)taosCloseFile(&pFile); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); return 0; #endif @@ -748,7 +749,7 @@ int32_t taosGetProcMemory(int64_t *usedKB) { char tmp[10]; (void)sscanf(line, "%s %" PRId64, tmp, usedKB); - (void)taosCloseFile(&pFile); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); return 0; #endif @@ -1045,7 +1046,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) { return terrno; } else { len = taosReadFile(pFile, uid, uidlen); - (void)taosCloseFile(&pFile); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); if (len < 0) { return len; } @@ -1087,7 +1088,7 @@ char *taosGetCmdlineByPID(int pid) { cmdline[n] = 0; - (void)taosCloseFile(&pFile); + TAOS_SKIP_ERROR(taosCloseFile(&pFile)); } else { cmdline[0] = 0; } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index bd22a4e42b..7d905e843d 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -215,7 +215,10 @@ int32_t taosInitSlowLog() { int32_t taosInitLog(const char *logName, int32_t maxFiles, bool tsc) { if (atomic_val_compare_exchange_8(&tsLogInited, 0, 1) != 0) return 0; - TAOS_CHECK_RETURN(osUpdate()); + int32_t code = osUpdate(); + if (code != 0) { + uError("failed to update os info, reason:%s", tstrerror(code)); + } TAOS_CHECK_RETURN(taosInitNormalLog(logName, maxFiles)); if (tsc){ From 3acac77f9f503ac5abef39dd53022ed16d4b21c6 Mon Sep 17 00:00:00 2001 From: xsren <285808407@qq.com> Date: Fri, 13 Sep 2024 16:41:13 +0800 Subject: [PATCH 4/4] build on mac --- source/os/src/osTimezone.c | 6 ++---- source/util/src/terror.c | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index 1d8a552862..89ced69f97 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -883,15 +883,13 @@ int32_t taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { int n = readlink("/etc/localtime", buf, sizeof(buf)); if (n < 0) { - printf("read /etc/localtime error, reason:%s\n", strerror(errno)); - return; + return TSDB_CODE_TIME_ERROR; } buf[n] = '\0'; char *zi = strstr(buf, "zoneinfo"); if (!zi) { - printf("parsing /etc/localtime failed\n"); - return; + return TSDB_CODE_TIME_ERROR; } tz = zi + strlen("zoneinfo") + 1; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 5ceec33831..31ede562bd 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -112,6 +112,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FAILED_TO_CONNECT_S3, "Failed to connect to TAOS_DEFINE_ERROR(TSDB_CODE_MSG_PREPROCESSED, "Message has been processed in preprocess") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_BUFFER, "Out of buffer") TAOS_DEFINE_ERROR(TSDB_CODE_INTERNAL_ERROR, "Internal error") +TAOS_DEFINE_ERROR(TSDB_CODE_TIME_ERROR, "Internal error in time") //client TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation")