From: Matteo Nastasi (mop) Date: Wed, 18 May 2011 21:47:21 +0000 (+0200) Subject: garbage management refactored X-Git-Tag: 3.5.5~2 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=8e6645e3502b269d768bbb43e30b70bf96a2cdaf;p=brisk.git garbage management refactored --- diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index bd5252f..fffd692 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -581,7 +581,7 @@ class Bin5_user extends User { static function load_data($tab_id, $id, $sess) { - log_main("Bin5_user::load_data: tab_id [".$tab_id."] id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); + log_load("Bin5_user::load_data: tab_id [".$tab_id."] id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); do { if (($tok = @ftok(FTOK_PATH."/bin5/table".$tab_id."/user".$id, "B")) == -1) { @@ -761,7 +761,7 @@ class Bin5 { $this->table_idx = $table_idx; $this->table_token = $table_token; - Bin5::garbage_time_expire_set(0); + Bin5::garbage_time_expire_set($table_idx, 0); log_wr("Bin5 constructor end"); } @@ -800,7 +800,7 @@ class Bin5 { $ismod = FALSE; $curtime = time(); // externalized if ($force || $this->garbage_timeout < $curtime) { - if ($force || Bin5::garbage_time_is_expired($curtime)) { + if ($force || Bin5::garbage_time_is_expired($this->table_idx, $curtime)) { for ($i = 0 ; $i < BIN5_MAX_PLAYERS ; $i++) { $user_cur = $this->user[$i]; if ($user_cur->sess == "" || @@ -839,7 +839,7 @@ class Bin5 { log_rd2($user_cur->sess." GARBAGE UPDATED!"); // externalized $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT; - Bin5::garbage_time_expire_set($curtime + GARBAGE_TIMEOUT); + Bin5::garbage_time_expire_set($this->table_idx, $curtime + GARBAGE_TIMEOUT); $ismod = TRUE; } @@ -1203,14 +1203,14 @@ class Bin5 { } - static function garbage_time_is_expired($tm) + static function garbage_time_is_expired($tab_id, $tm) { $ret = TRUE; $fp = FALSE; do { if (file_exists(BIN5_PROXY_PATH) == FALSE) mkdir(BIN5_PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/garbage_time.expired", 'rb')) == FALSE) + if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/garbage_time.expired", 'rb')) == FALSE) break; if (($s = fread($fp, 4)) == FALSE) break; @@ -1229,12 +1229,12 @@ class Bin5 { return ($ret); } - static function garbage_time_expire_set($tm) + static function garbage_time_expire_set($tab_id, $tm) { do { if (file_exists(BIN5_PROXY_PATH) == FALSE) mkdir(BIN5_PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/garbage_time.expired", 'wb')) == FALSE) + if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/garbage_time.expired", 'wb')) == FALSE) break; fwrite($fp, pack("L",$tm)); fclose($fp); diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index 1800f21..1de3bd6 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -83,8 +83,8 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $bri = FALSE; $user = FALSE; $curtime = time(); - - if (($proxy_step = Bin5_user::load_step($sess)) == FALSE) { + + if (($proxy_step = Bin5_user::load_step($table_idx, $sess)) == FALSE) { log_only2("R"); return (FALSE); } @@ -106,7 +106,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su Bin5_user::save_data($user, $table_idx, $user->idx); - if (Bin5::garbage_time_is_expired($curtime)) { + if (Bin5::garbage_time_is_expired($table_idx, $curtime)) { log_only("F"); $S_load_stat['R_garbage']++; @@ -288,7 +288,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $tmp_sess = $user->sess; $user->sess = ""; - step_unproxy($tmp_sess); + Bin5_user::unproxy_step($tmp_sess); $user->name = ""; $user->the_end = FALSE; @@ -334,7 +334,7 @@ if (!isset($myfrom)) $myfrom = ""; if (!isset($subst)) $subst = ""; -log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming."USER_AGENT:".$HTTP_USER_AGENT); +log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming."USER_AGENT:".$HTTP_USER_AGENT." TABLE:".$table_idx); $endtime = time() + STREAM_TIMEOUT; @@ -347,7 +347,7 @@ for ($i = 0 ; time() < $endtime ; $i++) { $pre_main = gettimeofday(TRUE); if (($ret = maincheck($sess, $old_stat, $old_subst, $old_step, &$stat, &$subst, &$step, $table_idx, $table_token)) != FALSE) { echo '@BEGIN@'; - // log_rd2(sprintf("\nSESS: [%s]\nOLD_STAT: [%s] OLD_SUBST: [%s] OLD_STEP: [%s] \nSTAT: [%s] SUBST: [%s] STEP: [%s] \nCOMM: [%s]\n", $sess, $old_stat, $old_subst, $old_step, $stat, $subst, $step, $ret)); + log_rd2(sprintf("\nSESS: [%s]\nOLD_STAT: [%s] OLD_SUBST: [%s] OLD_STEP: [%s] \nSTAT: [%s] SUBST: [%s] STEP: [%s] \nCOMM: [%s]\n", $sess, $old_stat, $old_subst, $old_step, $stat, $subst, $step, $ret)); echo "$ret"; echo ' @END@'; log_send("EXT_STEP: ".$ext_step." ENDTIME: [".$endtime."] ".$ret);