[netflow-tools] Some softflowd patches

Florian Weimer fweimer at bfk.de
Wed Jul 25 00:40:34 EST 2007


Here are a few patches for softflowd.

Without LOG_NDELAY in the openlog call, the actual open will be
delayed until the first syslog call.  At that point, it might fail
because of the previous chroot call.

The "volatile" hunk is probably not required because the compiler
needs to assume that the function pointer escapes from the signal
function anyway (it should be "volatile sig_atomic_t", but I don't
know if this is sufficiently portable).

The for(;;) patch is required for proper SIGTERM support (otherwise,
softflowd never reacts to SIGTERM, at least on Linux).

--- ../tmp/log.c	2004-09-10 11:08:08.000000000 +0200
+++ log.c	2007-07-24 14:18:23.000000000 +0200
@@ -38,7 +38,7 @@
 	if (to_stderr)
 		logstderr = 1;
 	else
-		openlog(PROGNAME, LOG_PID, LOG_DAEMON);
+		openlog(PROGNAME, LOG_PID | LOG_NDELAY, LOG_DAEMON);
 }
 
 void
--- ../tmp/softflowd.c	2006-11-02 07:23:29.000000000 +0100
+++ softflowd.c	2007-07-24 15:18:30.000000000 +0200
@@ -57,7 +57,7 @@
 static int verbose_flag = 0;		/* Debugging flag */
 
 /* Signal handler flags */
-static int graceful_shutdown_request = 0;	
+static volatile int graceful_shutdown_request = 0;	
 
 /* Context for libpcap callback functions */
 struct CB_CTXT {
@@ -1824,7 +1824,7 @@
 	cb_ctxt.ft = &flowtrack;
 	cb_ctxt.linktype = linktype;
 	cb_ctxt.want_v6 = target.dialect->v6_capable || always_v6;
-	for(;;) {
+	while (!graceful_shutdown_request) {
 		/*
 		 * Silly libpcap's timeout function doesn't work, so we
 		 * do it here (only if we are reading live)


-- 
Florian Weimer                <fweimer at bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99


More information about the netflow-tools mailing list