Merge pull request #27876 from taosdata/fix/TD-31870/os3
Fix/td 31870/os3
This commit is contained in:
commit
c32d8312bd
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1712,7 +1712,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));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,39 +876,28 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
char buf[4096] = {0};
|
||||
char *tz = NULL;
|
||||
{
|
||||
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;
|
||||
|
||||
// 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 +908,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 +922,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 +930,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 +938,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 +949,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 +963,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 +992,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 +1019,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 +1032,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
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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){
|
||||
|
|
Loading…
Reference in New Issue