Browse Source

Separate watchdog & stats timer signals

Yann Weber 4 years ago
parent
commit
c2bcf7691f
2 changed files with 8 additions and 2 deletions
  1. 1
    0
      include/stats.h
  2. 7
    2
      src/stats.c

+ 1
- 0
include/stats.h View File

@@ -29,6 +29,7 @@
29 29
 #include <string.h>
30 30
 
31 31
 #define PYFCGI_STATS_SZ (900)
32
+#define PYFCGI_STATS_SIGALRM 30
32 33
 
33 34
 typedef struct pyfcgi_stats_s pyfcgi_stats_t;
34 35
 typedef struct pyfcgi_stats_sample_s pyfcgi_stats_sample_t;

+ 7
- 2
src/stats.c View File

@@ -12,10 +12,15 @@ int pyfcgi_stats_init()
12 12
 {
13 13
 	struct sigaction act;
14 14
 	struct itimerspec timeout;
15
+	struct sigevent sev;
15 16
 
16 17
 	memset(&pyfcgi_stats, 0, sizeof(pyfcgi_stats_t));
17 18
 
18
-	if(timer_create(CLOCK_REALTIME, NULL, &(pyfcgi_stats.timerid)) < 0)
19
+	sev.sigev_notify = SIGEV_SIGNAL;
20
+	sev.sigev_signo = PYFCGI_STATS_SIGALRM;
21
+	sev.sigev_value.sival_int = 0;
22
+
23
+	if(timer_create(CLOCK_REALTIME, &sev, &(pyfcgi_stats.timerid)) < 0)
19 24
 	{
20 25
 		pyfcgi_log(LOG_ERR,
21 26
 			"Unable to create timer for stats collecting : %s",
@@ -27,7 +32,7 @@ int pyfcgi_stats_init()
27 32
 	sigemptyset(&act.sa_mask);
28 33
 	act.sa_flags = 0;
29 34
 	act.sa_restorer = NULL;
30
-	if(sigaction(SIGALRM, &act, &(pyfcgi_stats.oldact)) < 0)
35
+	if(sigaction(PYFCGI_STATS_SIGALRM, &act, &(pyfcgi_stats.oldact)) < 0)
31 36
 	{
32 37
 		pyfcgi_log(LOG_ERR,
33 38
 			"Unable to register signal handler for stats collecting : %s",

Loading…
Cancel
Save