aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy-devel
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2014-03-13 21:28:51 +0100
committerPiBa-NL <pba_2k3@yahoo.com>2014-03-13 21:28:51 +0100
commitea49050c536f8480124a3497efce4a31d91e3931 (patch)
tree159df9ee6b579e27ed11a1dc898e1214fac74812 /config/haproxy-devel
parent81a9356da1857aba8e7e03d956bfc092f699972a (diff)
downloadpfsense-packages-ea49050c536f8480124a3497efce4a31d91e3931.tar.gz
pfsense-packages-ea49050c536f8480124a3497efce4a31d91e3931.tar.bz2
pfsense-packages-ea49050c536f8480124a3497efce4a31d91e3931.zip
haproxy-devel, place lock while starting, to prevent the startup script starting haproxy twice and loosing track of already running pid's.
Diffstat (limited to 'config/haproxy-devel')
-rw-r--r--config/haproxy-devel/haproxy.inc18
1 files changed, 12 insertions, 6 deletions
diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc
index 9bc0dd80..9b2b5838 100644
--- a/config/haproxy-devel/haproxy.inc
+++ b/config/haproxy-devel/haproxy.inc
@@ -635,13 +635,11 @@ function write_backend($fd, $name, $pool, $frontend) {
function haproxy_configure() {
global $g;
// reload haproxy
- haproxy_writeconf("{$g['varetc_path']}/haproxy");
return haproxy_check_run(1);
}
function haproxy_check_and_run(&$messages, $reload) {
global $g;
- $configpath = "{$g['varetc_path']}/haproxy";
$testpath = "{$g['varetc_path']}/haproxy_test";
haproxy_writeconf($testpath);
$retval = exec("haproxy -c -V -f $testpath/haproxy.cfg 2>&1", $output, $err);
@@ -659,7 +657,6 @@ function haproxy_check_and_run(&$messages, $reload) {
$ok = strstr($retval, "Configuration file is valid");
if ($ok && $reload) {
global $haproxy_run_message;
- haproxy_writeconf($configpath);
rmdir_recursive($testpath);
$ok = haproxy_check_run(1) == 0;
$messages = $haproxy_run_message;
@@ -1134,8 +1131,12 @@ function load_ipfw_rules() {
function haproxy_check_run($reload) {
global $config, $g, $haproxy_run_message;
+ $haproxylock = lock("haproxy", LOCK_EX);
$a_global = &$config['installedpackages']['haproxy'];
$configpath = "{$g['varetc_path']}/haproxy";
+
+ if ($reload)
+ haproxy_writeconf($configpath);
if(isset($a_global['enable'])) {
if (isset($a_global['carpdev'])) {
@@ -1146,14 +1147,18 @@ function haproxy_check_run($reload) {
//exec("/bin/pkill -F /var/run/haproxy.pid haproxy");//doesnt work for multiple pid's in a pidfile
haproxy_kill();
}
+ unlock($haproxylock);
return (0);
} else if (haproxy_is_running() && $reload == 0) {
+ unlock($haproxylock);
return (0);
}
log_error("Starting haproxy on CARP master.");
/* fallthrough */
- } else if ($reload == 0)
+ } else if ($reload == 0){
+ unlock($haproxylock);
return (0);
+ }
if(use_transparent_clientip_proxying()) {
filter_configure();
@@ -1172,14 +1177,15 @@ function haproxy_check_run($reload) {
}
foreach($output as $line)
$haproxy_run_message .= "<br/>" . htmlspecialchars($line) . "\n";
- return ($errcode);
} else {
if ($reload && haproxy_is_running()) {
//exec("/bin/pkill -F /var/run/haproxy.pid haproxy");//doesnt work for multiple pid's in a pidfile
haproxy_kill();
}
- return (0);
+ $errcode = 0;
}
+ unlock($haproxylock);
+ return ($errcode);
}
function haproxy_kill($killimmediately = true) {