From 09af04fb91d8c595a643d35b6649374232b8c220 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 16 May 2009 23:56:35 -0400 Subject: Rely on our own error handling --- etc/inc/util.inc | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'etc/inc/util.inc') diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 6ee7072..b318f92 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -90,21 +90,28 @@ function config_unlock() { function lock($lock) { global $g, $cfglckkeyconsumers; - if (!$lock) - die("WARNING: You must give a name as parameter to lock() function."); + if (!$lock) + die("WARNING: You must give a name as parameter to lock() function."); if (!file_exists("{$g['tmp_path']}/{$lock}.lock")) - @touch("{$g['tmp_path']}/{$lock}.lock"); - $config_lock_key = ftok("{$g['tmp_path']}/{$lock}.lock", 'a'); - $cfglckkey = sem_get($config_lock_key, 1); - $cfglckkeyconsumers++; - if (!sem_acquire($cfglckkey)) { - log_error("WARNING: lock() - Could not acquire {$lock} lock!"); - sem_remove($cfglckkey); - return NULL; - } else if ($g['debug']) - log_error("lock() - Got {$file} lock."); + @touch("{$g['tmp_path']}/{$lock}.lock"); + + $config_lock_key = ftok("{$g['tmp_path']}/{$lock}.lock", 'a'); + $cfglckkey = sem_get($config_lock_key, 1); + $cfglckkeyconsumers++; + + // Rely on or own logging for errors here. + ini_set('error_reporting', E_NONE); + + if (!sem_acquire($cfglckkey)) { + log_error("WARNING: lock() - Could not acquire {$lock} lock!"); + sem_remove($cfglckkey); + return NULL; + } else if ($g['debug']) + log_error("lock() - Got {$file} lock."); + + ini_set('error_reporting', E_ALL & ~E_NOTICE); - return $cfglckkey; + return $cfglckkey; } /* unlock configuration file */ @@ -960,4 +967,4 @@ function is_interface_mismatch() { return $do_assign; } -?> +?> \ No newline at end of file -- cgit v1.1