summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2005-05-18 01:15:16 +0000
committerBill Marquette <billm@pfsense.org>2005-05-18 01:15:16 +0000
commit7cf78912321845d45886bda0675b2fef7c368d03 (patch)
treed0678df6fcc89bfb8301629fdbbbf53cec070899 /etc/inc
parent412ebed9a8af1ac163c1f071cbc3f1e239f99d7e (diff)
downloadpfsense-7cf78912321845d45886bda0675b2fef7c368d03.zip
pfsense-7cf78912321845d45886bda0675b2fef7c368d03.tar.gz
Allow for multiple calls to write_lock() within a single process
This will still clear out both the process and file lock if config_unlock() is called (intended feature)
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/config.inc11
1 files changed, 8 insertions, 3 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc
index 4ce5e21..25ccde5 100644
--- a/etc/inc/config.inc
+++ b/etc/inc/config.inc
@@ -630,8 +630,11 @@ function config_install($conffile) {
/* lock configuration file, decide that the lock file is stale after
10 seconds */
function config_lock() {
+ global $g, $process_lock;
- global $g;
+ /* No need to continue if we're the ones holding the lock */
+ if ($process_lock)
+ return;
$lockfile = "{$g['varrun_path']}/config.lock";
@@ -640,10 +643,12 @@ function config_lock() {
/* open the lock file in append mode to avoid race condition */
if ($fd = @fopen($lockfile, "x")) {
/* succeeded */
+ $process_lock = true;
fclose($fd);
return;
} else {
/* file locked, wait and try again */
+ $process_lock = false;
sleep(1);
$n++;
}
@@ -652,10 +657,10 @@ function config_lock() {
/* unlock configuration file */
function config_unlock() {
-
- global $g;
+ global $g, $process_lock;
$lockfile = "{$g['varrun_path']}/config.lock";
+ $process_lock = false;
if (file_exists($lockfile))
unlink($lockfile);
OpenPOWER on IntegriCloud