From 6405333995acc0107254f9d8a16ffc427097253f Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 23 May 2012 12:54:51 +0000 Subject: [PATCH] Prevent 2 instances of rc.prunecaptiveportal from running in parallell since this might be a bad thing --- etc/rc.prunecaptiveportal | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etc/rc.prunecaptiveportal b/etc/rc.prunecaptiveportal index ee6c943a8a..3a8620ff3d 100755 --- a/etc/rc.prunecaptiveportal +++ b/etc/rc.prunecaptiveportal @@ -38,7 +38,17 @@ require_once("filter.inc"); require_once("shaper.inc"); require_once("captiveportal.inc"); +global $g; + $cpzone = str_replace("\n", "", $argv[1]); + +if (file_exists("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running")) { + log_error("Skipping CP prunning process because previous/another instance is already running"); + return; +} + +@file_put_contents("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running", ""); captiveportal_prune_old(); +@unlink("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running"); ?>