X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fauth.phh;h=193bca63a551b1c54cad6a63416ff72a2e8d5fc4;hb=4542fee714762f3f2d1b29ad276dd44f24be3aaa;hp=00add0c260e8a3aec26f418f2d21b5b084152231;hpb=78f44060729d1f0c82a396aab1d05cbb75226d2d;p=brisk.git diff --git a/web/Obj/auth.phh b/web/Obj/auth.phh index 00add0c..193bca6 100644 --- a/web/Obj/auth.phh +++ b/web/Obj/auth.phh @@ -2,7 +2,7 @@ /* * brisk - auth.phh * - * Copyright (C) 2006-2011 Matteo Nastasi + * Copyright (C) 2006-2012 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -24,11 +24,11 @@ require_once("${G_base}Obj/dbase_${G_dbasetype}.phh"); -define(CHAL_SHM_DIMS_MIN, 16384); -define(CHAL_SHM_DIMS_MAX, 65536); -define(CHAL_SHM_DIMS_DLT, 16384); -define(CHAL_VALID_TIME, 15); -define(CHAL_GARBAGE_TIMEOUT, 5); +define('CHAL_SHM_DIMS_MIN', 16384); +define('CHAL_SHM_DIMS_MAX', 65536); +define('CHAL_SHM_DIMS_DLT', 16384); +define('CHAL_VALID_TIME', 15); +define('CHAL_GARBAGE_TIMEOUT', 5); class Challenge { @@ -166,7 +166,7 @@ class Challenges { { GLOBAL $sess; do { - if (($tok = @ftok(FTOK_PATH."/challenges", "B")) == -1) { + if (($tok = @ftok(FTOK_PATH."/challenges", "C")) == -1) { log_main("ftok failed"); break; } @@ -212,7 +212,7 @@ class Challenges { $shm = FALSE; $oldmod = $chals->mod; - if (($tok = @ftok(FTOK_PATH."/challenges", "B")) == -1) + if (($tok = @ftok(FTOK_PATH."/challenges", "C")) == -1) return (FALSE); while ($chals->shm_sz < CHAL_SHM_DIMS_MAX) { @@ -244,22 +244,16 @@ class Challenges { return (FALSE); } - static function lock_data() + static function lock_data($is_exclusive) { - if (($tok = @ftok(FTOK_PATH."/challenges", "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 challenges [".self::$delta_t."]"); - return ($res); - } - else - return (FALSE); + if (($res = file_lock(FTOK_PATH."/challenges", $is_exclusive)) != FALSE) { + self::$delta_t = microtime(TRUE); + log_lock("LOCK challenges [".self::$delta_t."]"); + + return ($res); + } + + return (FALSE); } static function unlock_data($res) @@ -268,8 +262,8 @@ class Challenges { log_lock("UNLOCK challenges [".(microtime(TRUE) - (self::$delta_t))."]"); - return (sem_release($res)); + file_unlock($res); } } // End CLASS Challenges -?> \ No newline at end of file +?>