From: Matteo Nastasi (mop) Date: Sun, 3 Feb 2008 17:28:07 +0000 (+0000) Subject: game token, table recovery, clean of table data X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=a2924d2335ec5325dc322600fe373625575ac8e2;p=brisk.git game token, table recovery, clean of table data --- diff --git a/TODO.txt b/TODO.txt index 684952a..21836b5 100644 --- a/TODO.txt +++ b/TODO.txt @@ -9,16 +9,17 @@ URGENT - tables spawn DONE - spawn of a table DONE - data to cookies (removed table_idx from xhr calls also) - closure of a table - DONE set subst to shutdowner/shutdowned - DONE return to index.php + DONE - set subst to shutdowner/shutdowned + DONE - return to index.php + DONE - game's token + DONE - recover of corrupted table data - recover of users - flush of the table (after all recovers we can decide where and how destroy the table) + DONE - closure of a table + HALF - flush of the table (remove the shm ??) - game's token - security checks for right scope access garbage collector management + + HALF - security checks for right scope access optimizations inheritance diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index c248022..f0f3d75 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -459,6 +459,7 @@ class User { var $exitislock; // Player can exit from the table ? var $table; // id of the current table (if in table state) var $table_pos; // idx on the table + var $table_token;// token that identify a game on a table var $the_end; // Flag to change the end of the session function User() { @@ -487,7 +488,9 @@ class User { $thiz->exitislock = TRUE; $thiz->table = $table; - + $thiz->table_pos = -1; + $thiz->table_token = ""; + return ($thiz); } @@ -498,30 +501,31 @@ class User { if (($thiz = new User()) == FALSE) return ($G_false); - $thiz->name = $from->name; - $thiz->sess = $from->sess; - $thiz->ip = $from->ip; - $thiz->lacc = $from->lacc; - $thiz->laccwr = $from->laccwr; - $thiz->bantime = $from->bantime; - $thiz->stat = $from->stat; - $thiz->subst = $from->subst; - $thiz->step = $from->step; + $thiz->name = $from->name; + $thiz->sess = $from->sess; + $thiz->ip = $from->ip; + $thiz->lacc = $from->lacc; + $thiz->laccwr = $from->laccwr; + $thiz->bantime = $from->bantime; + $thiz->stat = $from->stat; + $thiz->subst = $from->subst; + $thiz->step = $from->step; $thiz->trans_step = $from->trans_step; - $thiz->comm = array(); + $thiz->comm = array(); $i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N)); for ($i = $i_start ; $i < $from->step ; $i++) { $ii = $i % COMM_N; - $thiz->comm[$ii] = $from->comm[$ii]; + $thiz->comm[$ii] = $from->comm[$ii]; } - $thiz->asta_card = $from->asta_card; - $thiz->asta_pnt = $from->asta_pnt; - $thiz->handpt = $from->handpt; + $thiz->asta_card = $from->asta_card; + $thiz->asta_pnt = $from->asta_pnt; + $thiz->handpt = $from->handpt; $thiz->exitislock = $from->exitislock; - $thiz->table = $from->table; - $thiz->table_pos = $from->table_pos; - $thiz->the_end = $from->the_end; + $thiz->table = $from->table; + $thiz->table_pos = $from->table_pos; + $thiz->table_token = $from->table_token; + $thiz->the_end = $from->the_end; return ($thiz); } @@ -560,6 +564,7 @@ class User { $thiz->table = $table; $thiz->table_pos = $table_pos; + $thiz->table_token = $from->table_token; return ($thiz); } @@ -802,17 +807,19 @@ class Room { $table_idx = $user->table; $table = &$this->table[$table_idx]; - log_main("JOIN_WAKEUP", "begin function table:".$table_idx." stat: ".$user->stat." subst: ".$user->subst); + log_main($user->sess, "JOIN_WAKEUP: begin function table:".$table_idx." stat: ".$user->stat." subst: ".$user->subst); $curtime = time(); - - log_main("JOIN WAKEUP", "from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n); + $user_wup = array(); + $user_wup_n = 0; + log_main($user->sess, "JOIN WAKEUP: from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n); for ($i = 0 ; $i < $table->player_n ; $i++) { $user_cur = &$this->user[$table->player[$i]]; - log_main("PREIMPOST", "INLOOP name: ".$user_cur->name); + log_main($user->sess, "PREIMPOST INLOOP name: ".$user_cur->name); if ($user_cur->sess != "") { $user_cur->laccwr = $curtime; + log_load($user->sess, "cur: ".$user_cur->name." subst: ".$user_cur->subst); if ($user_cur->subst == "shutdowned") { $user_cur->stat_set("room"); $user_cur->subst = "sitdown"; @@ -821,47 +828,62 @@ class Room { $user_cur->stat_set("room"); $user_cur->subst = "standup"; $user_cur->table = -1; - $user_wup = &$user_cur; + $user_wup[$user_wup_n++] = &$user_cur; } } } + for ($wup_idx = 0 ; $wup_idx < $user_wup_n ; $wup_idx++) + $table->user_rem(&$this, &$user_wup[$wup_idx]); + /* aggiorna l'array dei giocatori al tavolo. */ - $table->user_rem(&$this, &$user_wup); for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { + log_main($user_cur->sess, "START LOOP"); $user_cur = &$this->user[$i]; - if ($user_cur->sess == '' || $user_cur->stat != 'room') + if ($user_cur->sess == '' || $user_cur->stat != 'room') { + log_main($user_cur->sess, "name: ".$user_cur->name."skip subst: ".$user_cur->subst); continue; - - log_main("VALORI", "name: ".$user_cur->name." tab: ".$user_cur->table." taix: ".$table_idx." ucur: ".$user_cur." us: ".$user); + } + + log_main($user->sess, "___"); + log_main($user->sess, "VALORI name: ".$user_cur->name." tab: ".$user_cur->table." taix: ".$table_idx." ucur: ".$user_cur." us: ".$user); $ret = "gst.st = ".($user_cur->step+1)."; "; if ($user_cur->stat == "room") { - log_main("DOCUMENT.index.php", "from table"); + log_main($user->sess, "DOCUMENT.index.php from table"); $ret .= table_content($this, $user_cur, $table_idx); $ret .= standup_content($this, $user_cur); - $act_content = table_act_content(FALSE, 0, $table_idx, $user->table); + $act_content = table_act_content(FALSE, 0, $table_idx, $user_cur->table); $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); - - if ($user_cur == $user_wup) { + for ($wup_idx = 0 ; $wup_idx < $user_wup_n ; $wup_idx++) + if ($user_cur == $user_wup[$wup_idx]) + break; + + log_main($user->sess, "JOIN_WAKEUP wup_idx ".$wup_idx." wup_n ".$user_wup_n); + + if ($wup_idx < $user_wup_n) { + log_main($user->sess, "JOIN_WAKEUP less"); // set the new status $ret .= 'subst = "standup"; '; // clean the action buttons in other tables for ($e = 0 ; $e < TABLES_N ; $e++) { if ($this->table[$e]->player_n < PLAYERS_N) - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, table_act_content(TRUE, 0, $e, $user->table)); + $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, table_act_content(TRUE, 0, $e, $user_cur->table)); } + log_main($user->sess, "JOIN_WAKEUP end less"); } else { + log_main($user->sess, "JOIN_WAKEUP more"); $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table); $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); + log_main($user->sess, "JOIN_WAKEUP end more"); } } - log_wr($user_cur->sess, "ROOM_JOIN_WAKEUP: ".$ret); + log_wr($user->sess, "ROOM_JOIN_WAKEUP: ".$ret); $user_cur->comm[$user_cur->step % COMM_N] = $ret; $user_cur->step_inc(); } diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 7805b2f..9e12289 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -5,13 +5,15 @@ class Briskin5 { var $user; var $table; var $table_idx; + var $table_token; + var $comm; // commands for many people var $step; // current step of the comm array var $garbage_timeout; var $tok; - function Briskin5 (&$room, $table_idx) { + function Briskin5 (&$room, $table_idx, $table_token) { $this->user = array(); $this->table = array(); @@ -25,11 +27,13 @@ class Briskin5 { log_wr("xxx", "Briskin5 constructor"); - for ($i = 0 ; $i < $table->player_n ; $i++) + for ($i = 0 ; $i < $table->player_n ; $i++) { + $user[$table->player[$i]]->table_token = $table_token; $this->user[$i] =& User::spawn(&$user[$table->player[$i]], 0, $i); - + } $this->table[0] =& Table::spawn(&$table); $this->table_idx = $table_idx; + $this->table_token = $table_token; $this->garbage_timeout = 0; log_wr("xxx", "Briskin5 constructor end"); @@ -119,7 +123,7 @@ class Briskin5 { // // static functions // - function &load_data($table_idx) + function &load_data($table_idx,$table_token) { GLOBAL $G_false, $sess; $shm = FALSE; @@ -137,6 +141,11 @@ class Briskin5 { if (($bri = @shm_get_var($shm, $tok)) == FALSE) break; + if ($bri->table_token != $table_token) { + log_wr($sess, "bri->table_token: ".$bri->table_token."table_token: ".$table_token); + + break; + } $bri->tok = $tok; shm_detach($shm); @@ -147,6 +156,8 @@ class Briskin5 { if ($shm != FALSE) shm_detach($shm); + + log_wr($sess, "briskin5 load_data failed"); return ($G_false); } @@ -160,6 +171,7 @@ class Briskin5 { $shm = FALSE; $isacq = FALSE; + log_main("XXX", "SAVE BRISKIN5 DATA"); // var_dump($bri); if (!isset($bri->tok)) @@ -197,20 +209,27 @@ class Briskin5 { // var_dump($bri); + log_main("XXX", "DESTROY BRISKIN5 DATA"); + if (!isset($bri->tok)) return (FALSE); do { $isacq = TRUE; - if (($shm = shm_attach($bri->tok, SHM_DIMS)) == FALSE) + log_main("XXX", "DESTROY2 BRISKIN5 DATA"); + if (($shm = shm_attach($bri->tok, SHM_DIMS)) === FALSE) break; - if (shm_remove($shm) == FALSE) { + if (shm_remove($shm) === FALSE) { log_only($sess, "REMOVE FALLITA ".strlen(serialize($bri))); log_only($sess, serialize($bri)); break; } + else { + $shm = FALSE; + log_main("XXX", "DESTROY2 BRISKIN5 DATA SUCCESS"); + } // log_main("XXX", "QUI CI ARRIVA [".$bri->user[0]->name."]"); $ret = TRUE; } while (0); @@ -361,11 +380,11 @@ class Briskin5 { { $table = &$this->table[0]; - log_main("WAKEUP", "begin function table stat: ".$user->stat." subst: ".$user->subst); + log_main("BRISKIN5_WAKEUP", "begin function table stat: ".$user->stat." subst: ".$user->subst); $curtime = time(); - log_main("WAKEUP", "from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n); + log_main("BRISKIN5_WAKEUP", "from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n); for ($i = 0 ; $i < $table->player_n ; $i++) { $user_cur = &$this->user[$i]; diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index 2d75d51..8573a5d 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -36,7 +36,7 @@ if (DEBUGGING == "local" && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') { function shutta() { - log_rd2("SHUTTA!", connection_status()); + log_rd2("bin5 SHUTTA!", connection_status()); } @@ -48,7 +48,7 @@ function unrecerror() $is_page_streaming = TRUE; log_rd2("XXX", "UNREC_ERROR"); - return (sprintf('the_end=true; window.onunload = null; document.location.assign("index.php");')); + return (sprintf('the_end=true; window.onunload = null; document.location.assign("../index.php");')); } function page_sync($sess, $page) @@ -63,21 +63,28 @@ function page_sync($sess, $page) -function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step, $table_idx) +function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step, $table_idx, $table_token) { GLOBAL $is_page_streaming, $first_loop; $ret = FALSE; $bri = FALSE; - log_rd2($sess, "M"); + // log_rd2($sess, "M"); /* Sync check (read only without modifications */ ignore_user_abort(TRUE); if (($sem = Briskin5::lock_data($table_idx)) != FALSE) { // Aggiorna l'expire time lato server if ($first_loop == TRUE) { log_only($sess, "F"); - $bri = &Briskin5::load_data($table_idx); + + // VERIFICARE TUTTE LE LOAD_DATA E PRENDERE CONTROMISURE NEL CASO FALLISCANO // + + if (($bri = &Briskin5::load_data($table_idx, $table_token)) == FALSE) { + Briskin5::unlock_data($sem); + ignore_user_abort(FALSE); + return (unrecerror()); + } if (($user = &$bri->get_user($sess, $idx)) == FALSE) { Briskin5::unlock_data($sem); ignore_user_abort(FALSE); @@ -99,10 +106,10 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su else { return (FALSE); } - + if (($proxy_step = step_get($sess)) != FALSE) { // log_rd2($sess, "Postget".$proxy_step."zizi"); - + if ($cur_step == $proxy_step) { log_only2($sess, "P"); return (FALSE); @@ -112,20 +119,26 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su } } else { - log_only2($sess, "R"); + log_only2($sess, "R"); } - + if ($bri == FALSE) { - ignore_user_abort(TRUE); - if (($sem = Briskin5::lock_data($table_idx)) != FALSE) { + do { + ignore_user_abort(TRUE); + if (($sem = Briskin5::lock_data($table_idx)) == FALSE) + break; + log_only($sess, "P"); - $bri = &Briskin5::load_data($table_idx); + if (($bri = &Briskin5::load_data($table_idx, $table_token)) == FALSE) + break; + } while (0); + + if ($sem != FALSE) Briskin5::unlock_data($sem); - ignore_user_abort(FALSE); - } - else { - return (FALSE); - } + + ignore_user_abort(FALSE); + if ($bri == FALSE) + return (unrecerror()); } if (($user = &$bri->get_user($sess, $idx)) == FALSE) { @@ -142,7 +155,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su // FUNZIONE from_scratch DA QUI ignore_user_abort(TRUE); $sem = Briskin5::lock_data($table_idx); - $bri = &Briskin5::load_data($table_idx); + $bri = &Briskin5::load_data($table_idx, $table_token); if (($user = &$bri->get_user($sess, $idx)) == FALSE) { Briskin5::unlock_data($sem); ignore_user_abort(FALSE); @@ -195,7 +208,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su else { ignore_user_abort(TRUE); $sem = Briskin5::lock_data($table_idx); - $bri = &Briskin5::load_data($table_idx); + $bri = &Briskin5::load_data($table_idx, $table_token); if (($user = &$bri->get_user($sess, $idx)) == FALSE) { Briskin5::unlock_data($sem); ignore_user_abort(FALSE); @@ -265,7 +278,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su */ $is_page_streaming = ((stristr($HTTP_USER_AGENT, "linux") && - stristr($HTTP_USER_AGENT, "firefox")) ? FALSE : TRUE); + (stristr($HTTP_USER_AGENT, "firefox") || stristr($HTTP_USER_AGENT, "iceweasel"))) ? FALSE : TRUE); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -275,7 +288,7 @@ if (!isset($myfrom)) $myfrom = ""; if (!isset($subst)) $subst = ""; -log_rd2($sess, "FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming); +log_rd2($sess, "FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming."USER_AGENT:".$HTTP_USER_AGENT); $endtime = time() + STREAM_TIMEOUT; @@ -285,7 +298,7 @@ $old_step = $ext_step = $step; for ($i = 0 ; time() < $endtime ; $i++) { // log_rd($sess, "PRE MAIN ".$step);; - if (($ret = maincheck($sess, $old_stat, $old_subst, $old_step, &$stat, &$subst, &$step, $table_idx)) != FALSE) { + if (($ret = maincheck($sess, $old_stat, $old_subst, $old_step, &$stat, &$subst, &$step, $table_idx, $table_token)) != FALSE) { echo '@BEGIN@'; // log_rd2($sess, 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"; diff --git a/web/briskin5/index_wr.php b/web/briskin5/index_wr.php index 1bca687..2fb6da2 100644 --- a/web/briskin5/index_wr.php +++ b/web/briskin5/index_wr.php @@ -40,7 +40,7 @@ if ($table_idx < 0 || $table_idx >= TABLE_N) exit; $sem = Briskin5::lock_data($table_idx); -$bri = &Briskin5::load_data($table_idx); +$bri = &Briskin5::load_data($table_idx,$table_token); if (($user = &$bri->get_user($sess, &$idx)) == FALSE) { echo "Get User Error"; log_wr($sess, "Get User Error"); @@ -61,7 +61,7 @@ if ($argz[0] == 'shutdown') { log_rd2($user->sess, "AUTO LOGOUT."); if ($user->subst == 'sitdown' || $user->stat == 'table') - $bri->room_wakeup(&$user); + $bri->table_wakeup(&$user); else if ($user->subst == 'standup') $bri->room_outstandup(&$user); else @@ -214,10 +214,10 @@ else if ($user->stat == 'room') { **********************/ else if ($user->subst == 'sitdown') { if ($argz[0] == 'wakeup') { - $bri->room_wakeup(&$user); + $bri->table_wakeup(&$user); } else if ($argz[0] == 'logout') { - $bri->room_wakeup(&$user); + $bri->table_wakeup(&$user); $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; $user->comm[$user->step % COMM_N] .= sprintf('postact_logout();'); $user->the_end = TRUE; diff --git a/web/index.php b/web/index.php index 9a1f0c6..475d3cf 100644 --- a/web/index.php +++ b/web/index.php @@ -32,7 +32,7 @@ log_load((isset($sess) ? $sess : "XXX"), "LOAD: index.php"); function main() { - GLOBAL $sess, $name, $table_idx, $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER; + GLOBAL $sess, $name, $table_idx, $table_token, $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER; $body = ""; $tables = ""; @@ -53,42 +53,66 @@ function main() $change_page = TRUE; log_load($sess, "resync from index.php"); - if (isset($table_idx)) { - $table_idx = (int)$table_idx; - log_load($sess, "SET TABLE_IDX ".TABLES_N); - if ($table_idx >= 0 && $table_idx < TABLES_N) { - log_load($sess, "SET TABLE_IDX GOOD VALUE"); - $bri_sem = Briskin5::lock_data($table_idx); - $bri = &Briskin5::load_data($table_idx); - - if (($bri_user = &$bri->get_user($sess, &$bri_idx)) != FALSE) { - if ($bri_user->subst == "shutdowned" || $bri_user->subst == "shutdowner") { - // QUI WAKEUP - $table = &$room->table[$user->table]; - $bri_table = &$bri->table[0]; - - for ($i = 0 ; $i < $bri_table->player_n ; $i++) { - $room->user[$table->player[$i]]->subst = $bri->user[$i]->subst; - $room->user[$table->player[$i]]->step = $bri->user[$i]->step; - $room->user[$table->player[$i]]->trans_step = $bri->user[$i]->step+1; - log_load($sess, "from table bri subst[".$i."]: ".$bri->user[$i]->subst); - log_load($sess, "from table roo subst[".$i."]: ".$room->user[$table->player[$i]]->subst); - } - - $room->room_join_wakeup(&$user); - - if (Room::save_data(&$room) == FALSE) { - echo "ERRORE SALVATAGGIO\n"; - exit; - } - - $change_page = FALSE; - } - log_load($sess, "from table subst: ".$bri_user->subst); + log_load($sess, "SET TABLE_IDX table.">".TABLES_N); + + log_load($sess, "SET TABLE_IDX GOOD VALUE"); + $bri_sem = Briskin5::lock_data($user->table); + if (($bri = &Briskin5::load_data($user->table, $table_token)) == FALSE) { + // table data error: recovery + + log_load($sess, "table data error: recovery".$user->table); + + $table = &$room->table[$user->table]; + for ($i = 0 ; $i < $table->player_n ; $i++) { + $user_cur = &$room->user[$table->player[$i]]; + $user_cur->subst = "shutdowner"; + $user_cur->step_inc(); + $user_cur->trans_step = $user_cur->step; + + $ret = sprintf('stat = "%s"; subst = "%s";', $cur_user->stat, $cur_user->subst); + $ret .= "gst.st = ".($user_cur->step+1)."; "; + $ret .= show_notify("
I dati del tavolo n°".$user->table." sono inconsistenti, verranno resettati.

Torni in piedi.

", 2000, "Chiudi.", 400, 110); + $user_cur->comm[$user_cur->step % COMM_N] = $ret; + $user_cur->step_inc(); + } + + $room->room_join_wakeup(&$user); + + if (Room::save_data(&$room) == FALSE) { + echo "ERRORE SALVATAGGIO\n"; + exit; + } + + $change_page = FALSE; + } + else if (($bri_user = &$bri->get_user($sess, &$bri_idx)) != FALSE) { + if ($bri_user->subst == "shutdowned" || $bri_user->subst == "shutdowner") { + // QUI WAKEUP + $table = &$room->table[$user->table]; + $bri_table = &$bri->table[0]; + + for ($i = 0 ; $i < $bri_table->player_n ; $i++) { + $room->user[$table->player[$i]]->subst = $bri->user[$i]->subst; + $room->user[$table->player[$i]]->step = $bri->user[$i]->step; + $room->user[$table->player[$i]]->trans_step = $bri->user[$i]->step+1; + log_load($sess, "from table bri subst[".$i."]: ".$bri->user[$i]->subst); + log_load($sess, "from table roo subst[".$i."]: ".$room->user[$table->player[$i]]->subst); + } + + $room->room_join_wakeup(&$user); + + if (Room::save_data(&$room) == FALSE) { + echo "ERRORE SALVATAGGIO\n"; + exit; } - Briskin5::unlock_data($bri_sem); + + $change_page = FALSE; + Briskin5::destroy_data(&$bri); } + log_load($sess, "from table subst: ".$bri_user->subst); } + Briskin5::unlock_data($bri_sem); + log_load($sess, "unlock Room"); if ($change_page) { Room::unlock_data($sem); diff --git a/web/index_rd.php b/web/index_rd.php index 93ac148..d9031f5 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -69,7 +69,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $ret = FALSE; $room = FALSE; - log_rd2($sess, "M"); + // log_rd2($sess, "M"); /* Sync check (read only without modifications */ ignore_user_abort(TRUE); if (($sem = Room::lock_data()) != FALSE) { @@ -115,16 +115,22 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su } if ($room == FALSE) { - ignore_user_abort(TRUE); - if (($sem = Room::lock_data()) != FALSE) { + do { + ignore_user_abort(TRUE); + if (($sem = Room::lock_data()) == FALSE) + break; + log_only($sess, "P"); - $room = &Room::load_data(); + if (($room = &Room::load_data()) == FALSE) + break; + } while (0); + + if ($sem != FALSE) Room::unlock_data($sem); - ignore_user_abort(FALSE); - } - else { + + ignore_user_abort(FALSE); + if ($room == FALSE) return (FALSE); - } } if (($user = &$room->get_user($sess, $idx)) == FALSE) { @@ -169,7 +175,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su } if ($cur_step == -1) { - log_rd2($sess, "PRE-NEWSTAT."); + log_rd2($sess, "PRE-NEWSTAT: ".$user->stat); if ($user->stat == 'room') { log_rd($sess, "roomma"); @@ -198,6 +204,9 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $new_subst = $user->subst; $new_step = $user->step; */ + log_rd2($sess, "ALL COMMENTED: ".$ret); + + } log_rd2($sess, "NEWSTAT: ".$user->stat); @@ -244,8 +253,10 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $user->name = ""; $user->the_end = FALSE; - if ($user->subst == 'sitdown') + if ($user->subst == 'sitdown') { + log_load($user->sess, "ROOM WAKEUP"); $room->room_wakeup(&$user); + } else if ($user->subst == 'standup') $room->room_outstandup(&$user); else @@ -275,7 +286,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su */ $is_page_streaming = ((stristr($HTTP_USER_AGENT, "linux") && - stristr($HTTP_USER_AGENT, "firefox")) ? FALSE : TRUE); + (stristr($HTTP_USER_AGENT, "firefox") || stristr($HTTP_USER_AGENT, "iceweasel"))) ? FALSE : TRUE); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 diff --git a/web/index_wr.php b/web/index_wr.php index b269c3b..54c0c3c 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -150,7 +150,8 @@ else if ($user->stat == 'room') { $curtime = time(); // Create new spawned table $bri_sem = Briskin5::lock_data($table_idx); - if (($bri =& new Briskin5(&$room, $table_idx)) == FALSE) + $table_token = uniqid(""); + if (($bri =& new Briskin5(&$room, $table_idx, $table_token)) == FALSE) log_wr($sess, "bri create: FALSE"); else log_wr($sess, "bri create: ".serialize($bri)); @@ -167,7 +168,7 @@ else if ($user->stat == 'room') { for ($i = 0 ; $i < $table->player_n ; $i++) { $bri_user_cur = &$bri->user[$i]; $user_cur = &$room->user[$table->player[$i]]; - + $bri_user_cur->trans_step = $user_cur->step + 1; $bri_user_cur->comm[$bri_user_cur->step % COMM_N] = ""; $bri_user_cur->step_inc(); @@ -184,7 +185,7 @@ else if ($user->stat == 'room') { log_wr($sess, "Pre if!"); $ret = ""; - $ret .= sprintf('gst.st_loc++; gst.st=%d; createCookie("table_idx", %d, 24*365, cookiepath); the_end=true; window.onunload = null ; document.location.assign("briskin5/briskin5.php");|', $user_cur->step+1, $table_idx); + $ret .= sprintf('gst.st_loc++; gst.st=%d; createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); the_end=true; window.onunload = null ; document.location.assign("briskin5/briskin5.php");|', $user_cur->step+1, $table_idx, $table_token); $user_cur->comm[$user_cur->step % COMM_N] = $ret; $user_cur->trans_step = $user_cur->step + 1;