aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2014-03-14 21:04:32 +0100
committerErmal Luçi <eri@pfsense.org>2014-03-14 21:04:32 +0100
commit0de5b6b80002794f5b65c0143eb65cf5e4a95f25 (patch)
tree64894f940c9f2a80c8f19161ceec72ee9a298cb4 /config
parent97f6aea7ce1261e2420763bb0468d45a0050326a (diff)
parentea49050c536f8480124a3497efce4a31d91e3931 (diff)
downloadpfsense-packages-0de5b6b80002794f5b65c0143eb65cf5e4a95f25.tar.gz
pfsense-packages-0de5b6b80002794f5b65c0143eb65cf5e4a95f25.tar.bz2
pfsense-packages-0de5b6b80002794f5b65c0143eb65cf5e4a95f25.zip
Merge pull request #625 from PiBa-NL/hap_starting_lock
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')
-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 517b4801..bde2cace 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;
@@ -1146,8 +1143,12 @@ function haproxy_plugin_carp($pluginparams) {
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'])) {
@@ -1158,14 +1159,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();
@@ -1184,14 +1189,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) {