优化 watchdog tfe worker thread 的实现逻辑
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user