未验证 提交 c76fb8f7 编写于 作者: L Linhe Huo 提交者: GitHub

[TS-1022]<fix>(other): fix alpine segmentation fault in startup (#9518)

上级 a2ee3a62
......@@ -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
......@@ -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;
......
......@@ -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 };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册