diff --git a/src/os/src/detail/osTimer.c b/src/os/src/detail/osTimer.c index 618df8a8bad451984fafd022a33a799986a48422..bc5119107a312b5f281263823d766e9ce506a85a 100644 --- a/src/os/src/detail/osTimer.c +++ b/src/os/src/detail/osTimer.c @@ -20,6 +20,7 @@ #if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) || defined(_TD_DARWIN_64)) +#ifndef _ALPINE static void taosDeleteTimer(void *tharg) { timer_t *pTimer = tharg; timer_delete(*pTimer); @@ -105,4 +106,41 @@ void taosUninitTimer() { pthread_join(timerThread, NULL); } +#else + +static timer_t timerId; + +void sig_alrm_handler(union sigval sv) { + void (*callback)(int) = sv.sival_ptr; + callback(0); +} +int taosInitTimer(void (*callback)(int), int ms) { + struct sigevent evp; + memset((void *)&evp, 0, sizeof(evp)); + evp.sigev_notify = SIGEV_THREAD; + evp.sigev_notify_function = &sig_alrm_handler; + evp.sigev_signo = SIGALRM; + evp.sigev_value.sival_ptr = (void *)callback; + + struct itimerspec ts; + ts.it_value.tv_sec = 0; + ts.it_value.tv_nsec = 1000000 * MSECONDS_PER_TICK; + ts.it_interval.tv_sec = 0; + ts.it_interval.tv_nsec = 1000000 * MSECONDS_PER_TICK; + if (timer_create(CLOCK_REALTIME, &evp, &timerId)) { + uError("Failed to create timer"); + return -1; + } + + if (timer_settime(timerId, 0, &ts, NULL)) { + uError("Failed to init timer"); + return -1; + } + return 0; +} + +void taosUninitTimer() { + timer_delete(timerId); +} +#endif #endif diff --git a/src/plugins/http/src/httpResp.c b/src/plugins/http/src/httpResp.c index a2452a16b94fea060a370c86518bb36c1da45070..2c18904d2a9cc2d2dca57c406134518028daba9b 100644 --- a/src/plugins/http/src/httpResp.c +++ b/src/plugins/http/src/httpResp.c @@ -156,7 +156,10 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) { HttpServer *pServer = &tsHttpServer; SMonHttpStatus *httpStatus = monGetHttpStatusHashTableEntry(httpCode); - pServer->statusCodeErrs[httpStatus->index] += 1; + // FIXME(@huolinhe): I don't known why the errors index is overflowed, but fix it by index check + if (httpStatus->index < HTTP_STATUS_CODE_NUM) { + pServer->statusCodeErrs[httpStatus->index] += 1; + } pContext->error = true; diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 78986d227a94ed2d1b2a224398d358ee67f448b2..67f7042033b495635f5de973774f65dcce35a0b1 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -375,6 +375,9 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) { fflush(stdout); return; } + if (flags == NULL || format == NULL) { + return; + } va_list argpointer; char buffer[MAX_LOGLINE_BUFFER_SIZE] = { 0 };