diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-05-08 18:42:37 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-05-08 18:42:37 +0000 |
commit | 0027de0a544438f146cfc94f005fd6f4ba9f94d7 (patch) | |
tree | 3f97d22951284c2a7b02563ecdbb0fd126b46f15 /etc/inc/pfsense-utils.inc | |
parent | 89e6e210158ca4ca24d2ddbc02ccab72175875a5 (diff) | |
download | pfsense-0027de0a544438f146cfc94f005fd6f4ba9f94d7.zip pfsense-0027de0a544438f146cfc94f005fd6f4ba9f94d7.tar.gz |
* Create two new functions lock($subsystem)/unlock() to have more reliable locking using semaphores.
This function can sleep till the resource is free and can help find not well behaving code.
* Remove most of the config_lock/config_unlock logics on the whole scripts/pages it is an abuse of this.
If any sybsytem wants to lock can do so with its own lock.
* Lock the config when doing a filter reload to avoid parallell recursion on this function, since it is not reentrant.
This compenstates for the removal of lock aquiring from the scripts/pages.
* config_lock/config_unlock are now compate shims that do nothing. They are preserved since packages 'abuse' them too.
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index c369ab6..9025fd7 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1912,45 +1912,6 @@ function pfsense_default_state_size() { return $max_states; } -/****f* pfsense-utils/safe_write_file - * NAME - * safe_write_file - Write a file out atomically - * DESCRIPTION - * safe_write_file() Writes a file out atomically by first writing to a - * temporary file of the same name but ending with the pid of the current - * process, them renaming the temporary file over the original. - * INPUTS - * $filename - string containing the filename of the file to write - * $content - string containing the file content to write to file - * $force_binary - boolean denoting whether we should force binary - * mode writing. - * RESULT - * boolean - true if successful, false if not - ******/ -function safe_write_file($file, $content, $force_binary) { - $tmp_file = $file . "." . getmypid(); - $write_mode = $force_binary ? "wb" : "w"; - - $fd = fopen($tmp_file, $write_mode); - if (!$fd) { - // Unable to open temporary file for writing - return false; - } - if (!fwrite($fd, $content)) { - // Unable to write to temporary file - fclose($fd); - return false; - } - fclose($fd); - - if (!rename($tmp_file, $file)) { - // Unable to move temporary file to original - unlink($tmp_file); - return false; - } - return true; -} - function rule_popup($src,$srcport,$dst,$dstport){ global $config; $aliases_array = array(); |