TSG-8331 完善TFE的Watchdog功能

This commit is contained in:
luwenpeng
2021-11-04 18:04:44 +03:00
parent cb15d3340f
commit 755c7efacf
2 changed files with 10 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
#include <assert.h>
#include <sys/prctl.h>
#include <stdlib.h>
#include <systemd/sd-daemon.h>
#include <proxy.h>
#include <platform.h>
@@ -52,6 +53,7 @@ static void watchdog_tfe_thread_handle(evutil_socket_t fd, short what, void *arg
struct watchdog_tfe *__ctx = proxy->watchdog_tfe;
struct timespec now;
time_t temp;
const char *check_result = "WATCHDOG=1";
clock_gettime(CLOCK_MONOTONIC, &now);
@@ -80,13 +82,18 @@ static void watchdog_tfe_thread_handle(evutil_socket_t fd, short what, void *arg
now.tv_sec, proxy->work_threads[i]->thread_id, proxy->work_threads[i]->readable_tid, temp, __ctx->cur_time_window_fail_cnt);
if (__ctx->cur_time_window_fail_cnt >= __ctx->timeout_cnt_as_fail)
{
TFE_LOG_ERROR(__ctx->logger, "Frome %ld to %ld, there are %d timeouts of the worker threads, Exit !!!",
TFE_LOG_ERROR(__ctx->logger, "Frome %ld to %ld, there are %d timeouts of the worker threads, Ready to Exit !!!",
__ctx->cur_time_window_begin, __ctx->cur_time_window_end, __ctx->cur_time_window_fail_cnt);
exit(-1);
check_result = "WATCHDOG=trigger";
}
}
}
}
if (sd_watchdog_enabled(0, NULL))
{
sd_notify(0, check_result);
}
}
struct watchdog_tfe *watchdog_tfe_create(struct tfe_proxy *proxy, const char *profile, void *logger)