X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fauth.phh;h=8e74ffd996feda1e2c6e49168184e48cfb61f112;hb=8fe1e432c4661ebf186026f920d778d37dbe0953;hp=eff784f77d25292a0b83f02174a5b710dc347a80;hpb=9b4aaeb974e7f92e6e124bde29c78a1f5f8fb2b0;p=brisk.git diff --git a/web/Obj/auth.phh b/web/Obj/auth.phh index eff784f..8e74ffd 100644 --- a/web/Obj/auth.phh +++ b/web/Obj/auth.phh @@ -47,6 +47,8 @@ class Challenge { } class Challenges { + static $delta_t; + var $item; var $item_n; var $mod; @@ -70,13 +72,13 @@ class Challenges { log_auth("xxx", sprintf("Challenges::add [%s]\n", $login)); // FIXME Checks here if ($login == '') { - return ($G_false); + return (FALSE); } // log_auth("xxx", "LOOPI tstamp: ".$this->item[$i]->tstamp." curtime: ".$curtime); - if (($chal = new Challenge($login, $token, $ip, $tstamp)) == null) { - return ($G_false); + if (($chal = new Challenge($login, $token, $ip, $tstamp)) == FALSE) { + return (FALSE); } $this->item[$this->item_n] = $chal; @@ -151,7 +153,7 @@ class Challenges { } // Static functions - function &init_data() + static function create() { $chal =& new Challenges(); @@ -160,14 +162,12 @@ class Challenges { return $chal; } - function &load_data() + function load_data() { - GLOBAL $G_false, $sess; - $doexit = FALSE; + GLOBAL $sess; do { if (($tok = @ftok(FTOK_PATH."/challenges", "B")) == -1) { log_main("ftok failed"); - $doexit = TRUE; break; } @@ -186,7 +186,7 @@ class Challenges { if ($chals == FALSE) { log_only("INIT CHALLENGES DATA"); - $chals =& Challenges::init_data(); + $chals =& Challenges::create(); if (@shm_put_var($shm, $tok, $chals) == FALSE) { log_only("PUT_VAR FALLITA ".strlen(serialize($chals))); log_only(serialize($chals)); @@ -199,18 +199,14 @@ class Challenges { $chals->garbage_manager(); - $ret = &$chals; - return ($ret); + return ($chals); } while (0); - if ($doexit) - exit(); - - return ($G_false); + return (FALSE); } - function save_data(&$chals) + function save_data($chals) { $shm = FALSE; $oldmod = $chals->mod; @@ -256,7 +252,8 @@ class Challenges { return (FALSE); } if (sem_acquire($res)) { - log_lock("LOCK challenges"); + self::$delta_t = microtime(TRUE); + log_lock("LOCK challenges [".self::$delta_t."]"); return ($res); } else @@ -267,7 +264,7 @@ class Challenges { { GLOBAL $sess; - log_lock("UNLOCK challenges"); + log_lock("UNLOCK challenges [".(microtime(TRUE) - (self::$delta_t))."]"); return (sem_release($res)); }