summaryrefslogtreecommitdiff
path: root/platform/src/proxy.cpp
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2021-08-20 11:32:33 +0800
committerluwenpeng <[email protected]>2021-08-20 15:36:58 +0800
commitf764a4bae1d23f2b182302ac80cac9878c7d4cd8 (patch)
tree24454bc4c99b6ad92a24a30791e26527addfe26a /platform/src/proxy.cpp
parentc41a67ca2b410c13bfdc651af4992d8f8bc824e4 (diff)
优化 watchdog tfe worker thread 的实现逻辑v4.5.12-202108
Diffstat (limited to 'platform/src/proxy.cpp')
-rw-r--r--platform/src/proxy.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp
index acdd45d..d3b895e 100644
--- a/platform/src/proxy.cpp
+++ b/platform/src/proxy.cpp
@@ -18,6 +18,7 @@
#include <getopt.h>
#include <libgen.h>
#include <unistd.h>
+#include <sys/syscall.h>
#include <event2/event.h>
#include <event2/dns.h>
@@ -47,6 +48,7 @@
#include <acceptor_kni_v2.h>
#include <acceptor_kni_v3.h>
#include <watchdog_kni.h>
+#include <watchdog_tfe.h>
#include <key_keeper.h>
/* Breakpad */
@@ -238,7 +240,7 @@ static void __dummy_event_handler(evutil_socket_t fd, short what, void * arg)
while (ATOMIC_READ(&(ctx->proxy->make_work_thread_sleep)) > 0)
{
- TFE_LOG_ERROR(g_default_logger, "recv SIGUSR1, make worker thread %d sleep", ctx->thread_id);
+ TFE_LOG_ERROR(g_default_logger, "recv SIGUSR1, make worker thread[%d] %d sleep", ctx->thread_id, ctx->readable_tid);
sleep(1);
}
}
@@ -290,6 +292,7 @@ static void * tfe_work_thread(void * arg)
{
struct tfe_thread_ctx * ctx = (struct tfe_thread_ctx *) arg;
struct timeval timer_delay = {2, 0};
+ ctx->readable_tid = syscall(SYS_gettid);
struct event * ev = event_new(ctx->evbase, -1, EV_PERSIST, __dummy_event_handler, ctx);
if (unlikely(ev == NULL))
@@ -534,12 +537,12 @@ void tfe_proxy_acceptor_init(struct tfe_proxy * proxy, const char * profile)
static void usage(char *cmd)
{
fprintf(stderr, "USAGE: %s [OPTIONS]\n", cmd);
- fprintf(stderr, " -v -- show version\n");
- fprintf(stderr, " -g -- generate coredump\n");
- fprintf(stderr, " -h -- show help info\n\n");
+ fprintf(stderr, " -v -- show version\n");
+ fprintf(stderr, " -g -- generate coredump\n");
+ fprintf(stderr, " -h -- show help info\n\n");
fprintf(stderr, "kill -s SIGHUP $pid -- reload zlog configure\n");
fprintf(stderr, "kill -s SIGUSR1 $pid -- make worker thread sleep\n");
- fprintf(stderr, "kill -s SIGUSR2 $pid -- wake worker thread form sleep\n");
+ fprintf(stderr, "kill -s SIGUSR2 $pid -- wake worker thread from sleep\n");
}
int main(int argc, char * argv[])
@@ -680,6 +683,10 @@ int main(int argc, char * argv[])
g_default_proxy->watchdog_kni = watchdog_kni_create(g_default_proxy, main_profile, g_default_logger);
CHECK_OR_EXIT(g_default_proxy->watchdog_kni != NULL, "Failed at creating KNI watchdog, Exit.");
+ /* Watchdog TFE */
+ g_default_proxy->watchdog_tfe = watchdog_tfe_create(g_default_proxy, main_profile, g_default_logger);
+ CHECK_OR_EXIT(g_default_proxy->watchdog_tfe != NULL, "Failed at creating TFE watchdog, Exit.");
+
TFE_LOG_ERROR(g_default_logger, "Tango Frontend Engine initialized, Version: %s.", __tfe_version);
/* If TFE is run by systemd's notify, then tell the systemd our tfe is ready.