summaryrefslogtreecommitdiffstats
path: root/plugin/firewall/eurephiafw.c
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/eurephiafw.c
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/eurephiafw.c')
-rw-r--r--plugin/firewall/eurephiafw.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/plugin/firewall/eurephiafw.c b/plugin/firewall/eurephiafw.c
index 4df4459..4c57ae5 100644
--- a/plugin/firewall/eurephiafw.c
+++ b/plugin/firewall/eurephiafw.c
@@ -28,6 +28,7 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <time.h>
#include "eurephia_struct.h"
#include "eurephia_log.h"
@@ -213,7 +214,7 @@ void eFW_StartFirewall(eurephiaCTX *ctx) {
void eFW_StopFirewall(eurephiaCTX *ctx) {
char buf[520], *fwdest = NULL;
- int childret = -1;
+ struct timespec tsp;
if( ctx->fwcfg == NULL ) {
return;
@@ -246,13 +247,30 @@ void eFW_StopFirewall(eurephiaCTX *ctx) {
kill(ctx->fwcfg->fwproc_pid, SIGABRT);
}
+ //
// Wait for the firewall module process to finish
- if( waitpid(ctx->fwcfg->fwproc_pid, &childret, 0) != ctx->fwcfg->fwproc_pid ) {
+ //
+
+ // prepare a timeout - 30 secounds should be enough
+ if( clock_gettime(CLOCK_REALTIME, &tsp) == -1 ) {
+ eurephia_log(ctx, LOG_FATAL, 0, "Could not prepare timeout for firewall shutdown: %s",
+ strerror(errno));
+ sleep(3);
+ kill(ctx->fwcfg->fwproc_pid, SIGABRT);
+ }
+ tsp.tv_sec += 30;
+
+ // Wait for shutdown accepted signal
+ if( sem_timedwait(ctx->fwcfg->thrdata.semp_worker, &tsp) == -1 ) {
eurephia_log(ctx, LOG_PANIC, 0, "Failed to wait for eFW module process to quit: %s",
strerror(errno));
+ sleep(3);
kill(ctx->fwcfg->fwproc_pid, SIGABRT);
}
+ // Send acknowledge back
+ sem_post(ctx->fwcfg->thrdata.semp_master);
+
free_nullsafe((*ctx->fwcfg).thrdata.fw_command);
free_nullsafe(ctx->fwcfg);
eurephia_log(ctx, LOG_INFO, 2, "eurephia firewall interface is stopped");