Update of /cvsroot/sysfence/sysfence
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9235
Modified Files:
mainloop.c mainloop.h sysfence.c
Log Message:
+ improved handling / blocking signals
Index: sysfence.c
===================================================================
RCS file: /cvsroot/sysfence/sysfence/sysfence.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- sysfence.c 26 May 2004 17:39:13 -0000 1.19
+++ sysfence.c 28 May 2004 20:36:50 -0000 1.20
@@ -139,20 +139,24 @@
/* child */
if (pid == 0) {
+ /* start handling signals */
+ signal_init (CHILD);
+
/* process title */
initproctitle (argc, argv);
- setproctitle (RULE_PROCESS, STATE_NORMAL, (*(shmruletab + i))->name);
+ rule = *(shmruletab + i);
+ setproctitle (RULE_PROCESS, STATE_NORMAL, rule->name);
/* one child process one ruleset */
rule_watch_loop (*(shmruletab + i));
} else /* parent */
{
/* start handling signals */
- signal_init ();
+ signal_init (PARENT);
/* process title */
initproctitle (argc, argv);
- setproctitle (MAIN_PROCESS, 0, NULL);
+ setproctitle (MAIN_PROCESS, STATE_NORMAL, NULL);
/* parent goes into data-providing loop */
res_probe_loop (main_db);
Index: mainloop.c
===================================================================
RCS file: /cvsroot/sysfence/sysfence/mainloop.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mainloop.c 26 May 2004 17:39:13 -0000 1.12
+++ mainloop.c 28 May 2004 20:36:50 -0000 1.13
@@ -25,6 +25,7 @@
#include "sys/communication.h"
#include "mainloop.h"
#include "sys/processtitle.h"
+#include "sys/sighandlers.h"
int step = 10;
@@ -34,10 +35,12 @@
/* save result of this and previous hit */
rule->prevhit = rule->hit;
- /* set semaphore while checking data */
+ /* set semaphore while checking data and block signals */
+ signals_handling (SIGBLOCK);
semaphore_wait (semid);
rule->hit = check_expression (rule->expr);
semaphore_post (semid);
+ signals_handling (SIGUNBLOCK);
if (rule->hit) {
#ifdef DEBUG
@@ -46,9 +49,11 @@
/* first - log if neccessary */
if (rule->log != NULL) {
if (! (rule->log->once && rule->prevhit)) {
+ signals_handling (SIGBLOCK);
semaphore_wait (semid);
log_rulehit (rule);
semaphore_post (semid);
+ signals_handling (SIGUNBLOCK);
#ifdef DEBUG
printf ("rule logged\n");
#endif
@@ -81,12 +86,14 @@
{
while (1) {
- /* set semaphore while changing data */
+ /* set semaphore while changing data and block signals */
+ signals_handling (SIGBLOCK);
semaphore_wait (semid);
fetch_la (db);
fetch_mem (db);
fetch_fs (db);
semaphore_post (semid);
+ signals_handling (SIGUNBLOCK);
sleep (step);
}
Index: mainloop.h
===================================================================
RCS file: /cvsroot/sysfence/sysfence/mainloop.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mainloop.h 23 May 2004 20:52:22 -0000 1.4
+++ mainloop.h 28 May 2004 20:36:50 -0000 1.5
@@ -18,6 +18,7 @@
int rule_shmid;
int *ruleprocesses;
int rulecount;
+sf_rule *rule;
void rule_watch_loop (sf_rule *rule);
void res_probe_loop (sf_database *db);
|