X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fbriskin5%2FObj%2Fbriskin5.phh;h=bd5252f91c9e2aa6b49e5b6ee51c2635578de7e5;hb=65680887c5bd1afa00e4cddc2877f7bb1a3cd58c;hp=3da15451732e63b85bf1304502167c5f396f7144;hpb=8fe1e432c4661ebf186026f920d778d37dbe0953;p=brisk.git diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 3da1545..bd5252f 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -520,7 +520,7 @@ class Bin5_user extends User { return (TRUE); } - static function load_step($sess) + static function load_step($tab_id, $sess) { $fp = FALSE; do { @@ -529,7 +529,7 @@ class Bin5_user extends User { if (file_exists(BIN5_PROXY_PATH) == FALSE) mkdir(BIN5_PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/".$sess.".step", 'rb')) == FALSE) + if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/".$sess.".step", 'rb')) == FALSE) break; if (($s = fread($fp, 8)) == FALSE) break; @@ -557,7 +557,7 @@ class Bin5_user extends User { break; if (file_exists(BIN5_PROXY_PATH) == FALSE) mkdir(BIN5_PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE) + if (($fp = @fopen(BIN5_PROXY_PATH."/table".$this->table_orig."/".$this->sess.".step", 'w')) == FALSE) break; fwrite($fp, pack("LL",$this->step, $this->idx)); fclose($fp); @@ -570,6 +570,14 @@ class Bin5_user extends User { return (FALSE); } + static function unproxy_step($tab_id, $sess) + { + log_rd2("UNPROXY: ".BIN5_PROXY_PATH."/table".$tab_id."/".$sess.".step"); + if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE) + return; + + @unlink(BIN5_PROXY_PATH."/table".$tab_id."/".$sess.".step"); + } static function load_data($tab_id, $id, $sess) { @@ -589,7 +597,9 @@ class Bin5_user extends User { $shm_sz = SHM_DIMS_U_MIN; if ($shm = shm_attach($tok, $shm_sz)) { - $user = @shm_get_var($shm, $tok); + if (($user = @shm_get_var($shm, $tok)) == FALSE) { + break; + } if ($sess != FALSE && $user->sess != $sess) { break; @@ -602,6 +612,8 @@ class Bin5_user extends User { // SHSPLIT FIXME: init_data for User class ?? $user = User::create($id, "", ""); if (@shm_put_var($shm, $tok, $user) == FALSE) { + log_shme("Bin5_user::save_data2"); + log_only("PUT_VAR FALLITA ".strlen(serialize($user))); log_only(serialize($user)); } @@ -611,7 +623,7 @@ class Bin5_user extends User { // This part isn't strictly required but is good to verify // the coerence of cached and User class saved value of step field. $old_step = $user->step; - $arr = Bin5_user::load_step($sess); + $arr = Bin5_user::load_step($tab_id, $sess); $user->step = $arr['s']; if ($old_step != $user->step) { log_crit("Bin5:: steps are diffetents User->step ".$user->step." Old_step: ".$old_step); @@ -650,10 +662,13 @@ class Bin5_user extends User { break; // log_only("PUT_VAR DI ".strlen(serialize($user))); - if (shm_put_var($shm, $tok, $user) != FALSE) { + if (@shm_put_var($shm, $tok, $user) != FALSE) { shm_detach($shm); $user->save_step(); log_main("User[".$id."] saved."); + + log_shme("Bin5_user::save_data"); + return (TRUE); } if (shm_remove($shm) === FALSE) { @@ -670,6 +685,36 @@ class Bin5_user extends User { return (FALSE); } + function destroy_data($tab_id) + { + do { + if (($tok = @ftok(FTOK_PATH."/bin5/table".$tab_id."/user".$this->table_pos, "B")) == -1) { + log_crit("BIN5 USER DATA REMOVE FAILED 1 [".FTOK_PATH."/bin5/table".$tab_id."/user".$this->table_pos."]"); + break; + } + + if (($shm = @shmop_open($tok, 'a', 0, 0)) == FALSE) { + log_crit("BIN5 USER DATA REMOVE FAILED 2"); + break; + } + if (shmop_delete($shm) == 0) { + log_crit("BIN5 USER DATA REMOVE FAILED 3"); + break; + } + $shm = FALSE; + + log_main("BIN5 USER DATA DESTROY SUCCESS"); + + // log_main("QUI CI ARRIVA [".$bri->user[0]->name."]"); + $ret = TRUE; + } while (0); + + if ($shm) + shm_detach($shm); + + return ($ret); + } + } // end class Bin5_user @@ -772,7 +817,7 @@ class Bin5 { $tmp_sess = $user_cur->sess; $user_cur->sess = ""; - step_unproxy($tmp_sess); + Bin5_user::step_unproxy($tmp_sess); $user_cur->name = ""; $user_cur->the_end = FALSE; @@ -880,6 +925,9 @@ class Bin5 { break; if (@shm_put_var($shm, $bri->tok, $bri) != FALSE) { + + log_shme("Bin5::save_data"); + $ret = TRUE; break; } @@ -906,7 +954,7 @@ class Bin5 { - function destroy_data($table_idx) + function destroy_data() { GLOBAL $sess; @@ -915,9 +963,12 @@ class Bin5 { log_main("DESTROY BRISKIN5 DATA"); do { - log_main("DESTROY2 BRISKIN5 DATA"); - - if (($tok = @ftok(FTOK_PATH."/bin5/table".$table_idx."/table", "B")) == -1) + log_main("DESTROY2 BRISKIN5 DATA [".$this->table_idx."]"); + for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) { + $this->user[$i]->destroy_data($this->table_idx); + Bin5_user::unproxy_step($this->table_idx, $this->user[$i]->sess); + } + if (($tok = @ftok(FTOK_PATH."/bin5/table".$this->table_idx."/table", "B")) == -1) break; if (($shm = @shmop_open($tok, 'a', 0, 0)) == FALSE)