summaryrefslogtreecommitdiffstats
path: root/plugin/firewall/iptables
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-11-01 12:13:52 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-11-01 12:13:52 +0100
commit64f6478a2dac17994566c4d59a302bd4f816b31f (patch)
treec8539a3ec275d46b99b6868b1bcb3850f00271f9 /plugin/firewall/iptables
parente2b56924035977f1a8aac1b87372ad0be6eb51e8 (diff)
downloadeurephia-64f6478a2dac17994566c4d59a302bd4f816b31f.tar.gz
eurephia-64f6478a2dac17994566c4d59a302bd4f816b31f.tar.xz
eurephia-64f6478a2dac17994566c4d59a302bd4f816b31f.zip
BUGFIX (2/2) ... implemented master side fix of shutdown bug
Also changed the worker side to use sem_timedwait(), to not wait forever on shutdown acknowledge
Diffstat (limited to 'plugin/firewall/iptables')
-rw-r--r--plugin/firewall/iptables/efw_iptables.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/plugin/firewall/iptables/efw_iptables.c b/plugin/firewall/iptables/efw_iptables.c
index 3d173d3..f238222 100644
--- a/plugin/firewall/iptables/efw_iptables.c
+++ b/plugin/firewall/iptables/efw_iptables.c
@@ -26,6 +26,7 @@
#include <pthread.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <time.h>
#include <eurephia_nullsafe.h>
#include <eurephia_log.h>
@@ -54,6 +55,7 @@ void eFW_RunFirewall(void *fwargs) {
int quit = 0;
unsigned int prio;
char buf[EFW_MSG_SIZE+2];
+ struct timespec tsp;
DEBUG(ctx, 28, "eFW_RunFirewall: Waiting for eFW master to get ready");
sem_wait(cfg->semp_master);
@@ -67,6 +69,8 @@ void eFW_RunFirewall(void *fwargs) {
exit(3);
}
+ eurephia_log(ctx, LOG_INFO, 1, "efw_iptables: Firewall interface started");
+
// Main loop ... grab messages of the messague queue until shutdown command is sent, or a failure happens
while( quit == 0 ) {
memset(buf, 0, EFW_MSG_SIZE+2);
@@ -98,8 +102,22 @@ void eFW_RunFirewall(void *fwargs) {
sem_post(cfg->semp_worker);
DEBUG(ctx, 28, "eFW_RunFirewall: Waiting for eFW master to acknowledge");
- sem_wait(cfg->semp_master);
-
+ // Prepare a timeout
+ if( clock_gettime(CLOCK_REALTIME, &tsp) == -1 ) {
+ eurephia_log(ctx, LOG_FATAL, 0, "eFW_RunFirewall: Could not prepare timeout for shutdown ack: %s",
+ strerror(errno));
+ sleep(10);
+ } else {
+ tsp.tv_sec += 30; // Wait up to 30 seconds for shutdown ack.
+
+ // Wait for acknowledge
+ if( sem_timedwait(cfg->semp_master, &tsp) == -1 ) {
+ eurephia_log(ctx, LOG_PANIC, 0, "eFW_RunFirewall: Did not receive any shutdown ack: %s",
+ strerror(errno));
+ } else {
+ eurephia_log(ctx, LOG_INFO, 1, "efw_iptables: Firewall interface shutdown");
+ }
+ }
efwRemoveSemaphores(ctx, fwargs);
exit(0);
}