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

+ 7
- 2
src/stats.c View File

12
 {
12
 {
13
 	struct sigaction act;
13
 	struct sigaction act;
14
 	struct itimerspec timeout;
14
 	struct itimerspec timeout;
15
+	struct sigevent sev;
15
 
16
 
16
 	memset(&pyfcgi_stats, 0, sizeof(pyfcgi_stats_t));
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
 		pyfcgi_log(LOG_ERR,
25
 		pyfcgi_log(LOG_ERR,
21
 			"Unable to create timer for stats collecting : %s",
26
 			"Unable to create timer for stats collecting : %s",
27
 	sigemptyset(&act.sa_mask);
32
 	sigemptyset(&act.sa_mask);
28
 	act.sa_flags = 0;
33
 	act.sa_flags = 0;
29
 	act.sa_restorer = NULL;
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
 		pyfcgi_log(LOG_ERR,
37
 		pyfcgi_log(LOG_ERR,
33
 			"Unable to register signal handler for stats collecting : %s",
38
 			"Unable to register signal handler for stats collecting : %s",

Loading…
Cancel
Save