From eade409a42bdb17e208dbf9f212ec7c9b6b0b4f1 Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 21 Jun 2010 11:06:50 +0000 Subject: Use proper locking. --- etc/inc/captiveportal.inc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'etc/inc/captiveportal.inc') diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 1b2d361..1e96b41 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -384,6 +384,9 @@ function captiveportal_init_rules($reinit = false) { } else return false; + if ($reinit == false) + $captiveportallck = lock('captiveportal'); + /* init dummynet/ipfw rules number database */ captiveportal_init_ipfw_ruleno(); @@ -526,10 +529,14 @@ EOD; $tmprules .= "flush\n"; $cprules = "{$tmprules}\n{$cprules}"; } - if (file_put_contents("{$g['tmp_path']}/ipfw.cp.rules", $cprules)) { - mwexec("/sbin/ipfw -q {$g['tmp_path']}/ipfw.cp.rules", true); - //@unlink("{$g['tmp_path']}/ipfw.cp.rules"); - } + + file_put_contents("{$g['tmp_path']}/ipfw.cp.rules", $cprules); + mwexec("/sbin/ipfw -q {$g['tmp_path']}/ipfw.cp.rules", true); + @unlink("{$g['tmp_path']}/ipfw.cp.rules"); + + if ($reinit == false) + unlock($captiveportallck); + /* filter on layer2 as well so we can check MAC addresses */ mwexec("/sbin/sysctl net.link.ether.ipfw=1"); -- cgit v1.1