From: Matteo Nastasi Date: Fri, 26 Oct 2012 06:58:30 +0000 (+0200) Subject: garbage_timeout variable replaces file storaged value X-Git-Tag: v4.0.0~21 X-Git-Url: http://mop.ddnsfree.com/gitweb/?p=brisk.git;a=commitdiff_plain;h=b1bb4eedabda830bd520f773928cd848c5dcb11a garbage_timeout variable replaces file storaged value --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 8879c85..62946ed 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -680,7 +680,7 @@ class Room { var $match; var $comm; // commands for many people var $step; // current step of the comm array - // externalized var $garbage_timeout; + var $garbage_timeout; var $shm_sz; function Room () { @@ -709,8 +709,7 @@ class Room { else $this->table[$i]->auth_only = FALSE; } - // externalized $this->garbage_timeout = 0; - Room::garbage_time_expire_set(0); + $this->garbage_timeout = 0; $this->shm_sz = SHM_DIMS_MIN; } @@ -725,8 +724,7 @@ class Room { /* Garbage collector degli utenti in timeout */ $curtime = time(); - // externalized if ($force || $this->garbage_timeout < $curtime) { - if (!$force && !Room::garbage_time_is_expired($curtime)) { + if (!$force && !($this->garbage_timeout < $curtime)) { return ($ismod); } @@ -874,8 +872,7 @@ class Room { } log_rd2("GARBAGE UPDATED!"); - // externalized $this->garbage_timeout = time() + GARBAGE_TIMEOUT; - Room::garbage_time_expire_set($curtime + GARBAGE_TIMEOUT); + $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT; $ismod = TRUE; return ($ismod); @@ -2135,48 +2132,6 @@ class Room { return ($ret); } - static function garbage_time_is_expired($tm) - { - $ret = TRUE; - $fp = FALSE; - do { - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'rb')) == FALSE) - break; - if (($s = fread($fp, 4)) == FALSE) - break; - if (mb_strlen($s, "ASCII") != 4) - break; - $arr = unpack('Le', $s); - if ($arr['e'] > $tm) - $ret = FALSE; - } while (0); - - if ($fp != FALSE) - fclose($fp); - - log_rd2("END: return ".($ret ? "TRUE" : "FALSE")); - - return ($ret); - } - - static function garbage_time_expire_set($tm) - { - do { - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'wb')) == FALSE) - break; - fwrite($fp, pack("L",$tm)); - fclose($fp); - - return (TRUE); - } while (0); - - return (FALSE); - } - function request_mgr(&$s_a_p, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) { printf("NEW_SOCKET (root): %d\n", intval($new_socket)); diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 1fc59a2..f993848 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -679,23 +679,6 @@ class User { $ret = FALSE; $curtime = time(); - /* if ((($curtime - $this->lacc) > STREAM_TIMEOUT) || Room::garbage_time_is_expired($curtime)) { */ - /* $S_load_stat['lL_laccgarb']++; */ - - /* if (($curtime - $this->lacc) >= STREAM_TIMEOUT) { */ - /* $S_load_stat['wU_lacc_upd']++; */ - /* $this->lacc = $curtime; */ - /* } */ - - /* if (Room::garbage_time_is_expired($curtime)) { */ - /* log_only("F"); */ - - /* $S_load_stat['wR_garbage']++; */ - /* log_main("pre garbage_manager TRE"); */ - /* $this->room->garbage_manager(FALSE); */ - /* } */ - /* } */ - /* Nothing changed, return. */ if ($cur_step == $this->step) return (FALSE); diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 8f5cd82..2354137 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -784,23 +784,6 @@ push(\"%s\"); $ret = FALSE; $curtime = time(); - /* if ((($curtime - $this->lacc) > STREAM_TIMEOUT) || Room::garbage_time_is_expired($curtime)) { */ - /* $S_load_stat['lL_laccgarb']++; */ - - /* if (($curtime - $this->lacc) >= STREAM_TIMEOUT) { */ - /* $S_load_stat['wU_lacc_upd']++; */ - /* $this->lacc = $curtime; */ - /* } */ - - /* if (Room::garbage_time_is_expired($curtime)) { */ - /* log_only("F"); */ - - /* $S_load_stat['wR_garbage']++; */ - /* log_main("pre garbage_manager TRE"); */ - /* $this->room->garbage_manager(FALSE); */ - /* } */ - /* } */ - /* Nothing changed, return. */ if ($cur_step == $this->step) return (FALSE); @@ -926,7 +909,7 @@ class Bin5 { var $table; var $comm; // commands for many people var $step; // current step of the comm array - // externalized var $garbage_timeout; + var $garbage_timeout; var $shm_sz; var $table_idx; @@ -984,7 +967,7 @@ class Bin5 { $this->table_idx = $table_idx; $this->table_token = $table_token; - Bin5::garbage_time_expire_set($table_idx, 0); + $this->garbage_timeout = 0; log_wr("Bin5 constructor end"); } @@ -1022,8 +1005,7 @@ class Bin5 { /* Garbage collector degli utenti in timeout */ $ismod = FALSE; $curtime = time(); - // externalized if ($force || $this->garbage_timeout < $curtime) { - if ($force || Bin5::garbage_time_is_expired($this->table_idx, $curtime)) { + if ($force || $this->garbage_timeout < $curtime) { for ($i = 0 ; $i < BIN5_MAX_PLAYERS ; $i++) { $user_cur = $this->user[$i]; if ($user_cur->sess == "" || @@ -1061,8 +1043,7 @@ class Bin5 { } log_rd2($user_cur->sess." GARBAGE UPDATED!"); - // externalized $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT; - Bin5::garbage_time_expire_set($this->table_idx, $curtime + GARBAGE_TIMEOUT); + $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT; $ismod = TRUE; } @@ -1408,49 +1389,6 @@ class Bin5 { return ($is_ab); } - - static function garbage_time_is_expired($tab_id, $tm) - { - $ret = TRUE; - $fp = FALSE; - do { - if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE) - mkdir(BIN5_PROXY_PATH."/table".$tab_id, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/garbage_time.expired", 'rb')) == FALSE) - break; - if (($s = fread($fp, 4)) == FALSE) - break; - if (mb_strlen($s, "ASCII") != 4) - break; - $arr = unpack('Le', $s); - if ($arr['e'] > $tm) - $ret = FALSE; - } while (0); - - if ($fp != FALSE) - fclose($fp); - - log_rd2("END: return ".($ret ? "TRUE" : "FALSE")); - - return ($ret); - } - - static function garbage_time_expire_set($tab_id, $tm) - { - do { - if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE) - mkdir(BIN5_PROXY_PATH."/table".$tab_id, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/garbage_time.expired", 'wb')) == FALSE) - break; - fwrite($fp, pack("L",$tm)); - fclose($fp); - - return (TRUE); - } while (0); - - return (FALSE); - } - static function request_mgr(&$s_a_p, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) { printf("NEW_SOCKET (root): %d\n", intval($new_socket));