X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fhardban.phh;h=1dd4b4eb1df4d70bafe2e5d9cfcb52e62918fc5a;hb=f6a4ad0c8fed8ed0d3bab5fba9842cf00576c028;hp=e26fc4c7d5355af81bf8f7dce97133c5c1397b0c;hpb=aff81ded58cbc8ce9678a56b634448b35e2ea804;p=brisk.git diff --git a/web/Obj/hardban.phh b/web/Obj/hardban.phh index e26fc4c..1dd4b4e 100644 --- a/web/Obj/hardban.phh +++ b/web/Obj/hardban.phh @@ -238,31 +238,25 @@ class Hardbans { return (FALSE); } - function lock_data() + static function lock_data($is_exclusive) { - if (($tok = @ftok(FTOK_PATH."/hardbans", "B")) == -1) { - return (FALSE); - } - // echo "FTOK ".$tok."
"; - if (($res = sem_get($tok)) == FALSE) { - return (FALSE); - } - if (sem_acquire($res)) { - self::$delta_t = microtime(TRUE); - log_lock("LOCK hardbans [".self::$delta_t."]"); - return ($res); - } - else + if (($res = file_lock(FTOK_PATH."/hardbans", $is_exclusive)) != FALSE) { + self::$delta_t = microtime(TRUE); + log_lock("LOCK hardbans [".self::$delta_t."]"); + + return ($res); + } + return (FALSE); } - function unlock_data($res) + static function unlock_data($res) { GLOBAL $sess; log_lock("UNLOCK hardbans [".(microtime(TRUE) - (self::$delta_t))."]"); - return (sem_release($res)); + file_unlock($res); } @@ -270,7 +264,7 @@ class Hardbans { { $bantime = -1; /* if it exists check for a valid challenge */ - if (($a_sem = Hardbans::lock_data()) != FALSE) { + if (($a_sem = Hardbans::lock_data(TRUE)) != FALSE) { if (($hban = &Hardbans::load_data()) != FALSE) { for ($e = 0 ; $e < $hban->item_n ; $e++) { @@ -304,7 +298,7 @@ class Hardbans { { $found = FALSE; /* if it exists check for a valid challenge */ - if (($a_sem = Hardbans::lock_data()) != FALSE) { + if (($a_sem = Hardbans::lock_data(TRUE)) != FALSE) { if (($hban = &Hardbans::load_data()) != FALSE) {