From c2bcf7691f31cf509da11df755063d96db1c90e0 Mon Sep 17 00:00:00 2001 From: Yann Weber Date: Sun, 11 Aug 2019 16:47:29 +0200 Subject: [PATCH] Separate watchdog & stats timer signals --- include/stats.h | 1 + src/stats.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/stats.h b/include/stats.h index 43d7e1e..f0831b8 100644 --- a/include/stats.h +++ b/include/stats.h @@ -29,6 +29,7 @@ #include #define PYFCGI_STATS_SZ (900) +#define PYFCGI_STATS_SIGALRM 30 typedef struct pyfcgi_stats_s pyfcgi_stats_t; typedef struct pyfcgi_stats_sample_s pyfcgi_stats_sample_t; diff --git a/src/stats.c b/src/stats.c index fbbc69e..5fe0b1c 100644 --- a/src/stats.c +++ b/src/stats.c @@ -12,10 +12,15 @@ int pyfcgi_stats_init() { struct sigaction act; struct itimerspec timeout; + struct sigevent sev; memset(&pyfcgi_stats, 0, sizeof(pyfcgi_stats_t)); - if(timer_create(CLOCK_REALTIME, NULL, &(pyfcgi_stats.timerid)) < 0) + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = PYFCGI_STATS_SIGALRM; + sev.sigev_value.sival_int = 0; + + if(timer_create(CLOCK_REALTIME, &sev, &(pyfcgi_stats.timerid)) < 0) { pyfcgi_log(LOG_ERR, "Unable to create timer for stats collecting : %s", @@ -27,7 +32,7 @@ int pyfcgi_stats_init() sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_restorer = NULL; - if(sigaction(SIGALRM, &act, &(pyfcgi_stats.oldact)) < 0) + if(sigaction(PYFCGI_STATS_SIGALRM, &act, &(pyfcgi_stats.oldact)) < 0) { pyfcgi_log(LOG_ERR, "Unable to register signal handler for stats collecting : %s",