From f402ea85540dde36f860954f4e8ae3c5c9313a84 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 19 Mar 2008 06:33:30 +0000 Subject: [PATCH 01/16] experimental optimization moved and commented --- web/index_rd.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/index_rd.php b/web/index_rd.php index 84f00f8..51986e1 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -187,6 +187,11 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su log_rd("roomma ".$user->step); $ret .= show_room(&$room, $user->step, &$user); + // TODO uncomment and test + // while (array_pop($user->comm) != NULL); + // $new_step = -1; + // $user->step_inc(COMM_N + 1); + // Room::save_data($room); /* NOTE the sets went common */ $new_stat = $user->stat; $new_subst = $user->subst; @@ -223,7 +228,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su return (page_sync($user->sess, ($to_stat == "table" ? "briskin5/index.php" : "index.php"), $user->table, $user->table_token)); } log_rd2("lost history, refresh from scratch"); - $new_step = -1; + $new_step = -1; break; } for ($i = $cur_step ; $i < $user->step ; $i++) { -- 2.17.1 From 03b56b29d58cbd66c9d6fefebe842221ceaa5e62 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 19 Mar 2008 06:34:05 +0000 Subject: [PATCH 02/16] experimental optimization added --- web/index_wr.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/index_wr.php b/web/index_wr.php index d4138ee..c80396d 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -190,6 +190,8 @@ else if ($user->stat == 'room') { log_wr("Pre if!"); + // CHECK + while (array_pop($user_cur->comm) != NULL); $ret = ""; $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/index.php");|', $user_cur->step+1, $table_idx, $table_token); -- 2.17.1 From b804ca474cbf9e02703043b2d6e41cf52c9889ed Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 19 Mar 2008 06:36:06 +0000 Subject: [PATCH 03/16] new shared mem management, experimental optimization added --- web/Obj/brisk.phh | 115 ++++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 40 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index bbd62b8..9497600 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -26,7 +26,10 @@ define(TABLES_N, 20); define(PLAYERS_N, 3); define(MAX_POINTS, 5); define(MAX_PLAYERS, (20 + (PLAYERS_N * TABLES_N))); -define(SHM_DIMS, (50000 + 10000 * TABLES_N + 15000 * MAX_PLAYERS)); +define(SHM_DIMS_MIN, (50000 + 10000 * TABLES_N + 15000 * MAX_PLAYERS)); +define(SHM_DIMS_MAX, SHM_DIMS_MIN + 1048576); +define(SHM_DIMS_DLT, 65536); + define(COMM_N, 12); define(COMM_GEN_N, 50); define(SESS_LEN, 13); @@ -58,9 +61,9 @@ define(BRISK_SINGLE_SESS, ""); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "spawn-0.9.2"; +$G_brisk_version = "spawn-0.9.3"; -$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': chiuso il bug dei tavoli bianchi, versione beta.', +$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); $table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non può risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.'); @@ -575,13 +578,14 @@ class User { $thiz->trans_step = $from->trans_step; $thiz->comm = array(); + /* $i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N)); for ($i = $i_start ; $i < $from->step ; $i++) { log_wr("TRY PUSH:".$i); $ii = $i % COMM_N; $thiz->comm[$ii] = $from->comm[$ii]; } - + */ $thiz->asta_card = $from->asta_card; $thiz->asta_pnt = $from->asta_pnt; $thiz->handpt = $from->handpt; @@ -625,8 +629,8 @@ class User { return (FALSE); } - function step_inc() { - $this->step++; + function step_inc($delta = 1) { + $this->step += $delta; if (validate_sess($this->sess)) { $fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w'); @@ -683,6 +687,7 @@ class Room { var $comm; // commands for many people var $step; // current step of the comm array var $garbage_timeout; + var $shm_sz; function Room () { $this->user = array(); @@ -998,6 +1003,9 @@ class Room { // for users that wakeup the room will be reconstructed by index_rd.php if ($tab_idx < $user_tab_n) { log_main("PRE show_room username: ".$user_cur->name." STEP: ".$user_cur->step); + + while (array_pop($user_cur->comm) != NULL); + $user_cur->trans_step = $user_cur->step + 1 + $trans_delta; $user_cur->comm[$user_cur->step % COMM_N] = ""; $user_cur->step_inc(); @@ -1322,34 +1330,47 @@ class Room { function &load_data() { GLOBAL $G_false, $sess; + $doexit = FALSE; + do { + if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) { + log_main("ftok failed"); + $doexit = TRUE; + break; + } - if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) { - echo "FTOK FAILED"; - exit; - } - - if ($shm = shm_attach($tok, SHM_DIMS)) { - $room = @shm_get_var($shm, $tok); - - log_only("bri == ".($room == FALSE ? "FALSE" : "TRUE")." bri === ".($room === FALSE ? "FALSE" : "TRUE")." bri isset ".(isset($room) ? "TRUE" : "FALSE")); - if (isset($room)) - log_only("bri count ".count($room)); - - if ($room == FALSE) { - log_only("INIT MAIN DATA"); + if (($shm_sz = sharedmem_sz($tok)) == -1) { + log_main("shmop_open failed"); + } + + if ($shm_sz == -1) + $shm_sz = SHM_DIMS_MIN; + + if ($shm = shm_attach($tok, $shm_sz)) { + $room = @shm_get_var($shm, $tok); - $room =& Room::init_data(); - if (shm_put_var($shm, $tok, $room) == FALSE) { - log_only("PUT_VAR FALLITA ".strlen(serialize($room))); - log_only(serialize($room)); + log_only("bri == ".($room == FALSE ? "FALSE" : "TRUE")." bri === ".($room === FALSE ? "FALSE" : "TRUE")." bri isset ".(isset($room) ? "TRUE" : "FALSE")); + if (isset($room)) + log_only("bri count ".count($room)); + + if ($room == FALSE) { + log_only("INIT MAIN DATA"); + + $room =& Room::init_data(); + if (@shm_put_var($shm, $tok, $room) == FALSE) { + log_only("PUT_VAR FALLITA ".strlen(serialize($room))); + log_only(serialize($room)); + } } + $room->shm_sz = $shm_sz; + + shm_detach($shm); } - - shm_detach($shm); - $ret = &$room; return ($ret); - } + } while (0); + + if ($doexit) + exit(); return ($G_false); } @@ -1361,29 +1382,29 @@ class Room { $ret = FALSE; $shm = FALSE; - $isacq = FALSE; // var_dump($room); if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) return (FALSE); - do { - $isacq = TRUE; - - if (($shm = shm_attach($tok, SHM_DIMS)) == FALSE) + while ($room->shm_sz < SHM_DIMS_MAX) { + if (($shm = shm_attach($tok, $room->shm_sz)) == FALSE) break; // log_only("PUT_VAR DI ".strlen(serialize($room))); - if (shm_put_var($shm, $tok, $room) == FALSE) { - log_only("PUT_VAR FALLITA ".strlen(serialize($room))); - log_only(serialize($room)); + if (shm_put_var($shm, $tok, $room) != FALSE) { + shm_detach($shm); + return (TRUE); + } + if (shm_remove($shm) === FALSE) { + log_only("REMOVE FALLITA"); break; } - // log_main("QUI CI ARRIVA [".$room->user[0]->name."]"); - $ret = TRUE; - } while (0); - + shm_detach($shm); + $room->shm_sz += SHM_DIMS_DLT; + } + if ($shm) shm_detach($shm); @@ -2299,4 +2320,18 @@ function secstoword($secs) return ($ret); } +function sharedmem_sz($tok) +{ + if (($shm_id = @shmop_open($tok, 'a', 0, 0)) == FALSE) { + log_main("shmop_open failed"); + return (-1); + } + $shm_sz = shmop_size($shm_id); + shmop_close($shm_id); + + log_main("shm_sz: ".$shm_sz." SHM_DIMS: ".SHM_DIMS); + return ($shm_sz); +} + + ?> -- 2.17.1 From 73da829130f1d1e82bbdf16474ad8628419db1f9 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 19 Mar 2008 06:37:21 +0000 Subject: [PATCH 04/16] removed cards_hidetake(win) dumb function --- web/briskin5/index_wr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/briskin5/index_wr.php b/web/briskin5/index_wr.php index 17d001d..c55f8f5 100644 --- a/web/briskin5/index_wr.php +++ b/web/briskin5/index_wr.php @@ -401,7 +401,7 @@ else if ($user->stat == 'table') { $turn_nex = ($table->gstart + $table->turn) % BRISKIN5_PLAYERS_N; log_wr(sprintf("The winner is: [%d] [%s]", $winner, $bri->user[$table->player[$winner]]->name)); - $card_take = sprintf("sleep(gst,2000);|cards_take(%d);|cards_hidetake($d);", + $card_take = sprintf("sleep(gst,2000);|cards_take(%d);", $winner, $winner); $player_cur = "remark_off();" . $card_take . "|"; if ($turn_cur != $turn_nex) -- 2.17.1 From 18b16ce1ecd95cc5e8c632c8610f7bd736dc6e9e Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 19 Mar 2008 06:38:06 +0000 Subject: [PATCH 05/16] new shared mem management --- web/briskin5/Obj/briskin5.phh | 80 ++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index f2147d6..024e8cd 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -1,7 +1,10 @@ user = array(); $this->table = array(); $this->the_end = FALSE; - + $this->shm_sz = BRISKIN5_SHM_MIN; if (($this->tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) { echo "FTOK FAILED"; exit; @@ -123,20 +127,24 @@ class Briskin5 { function &load_data($table_idx, $table_token = "") { GLOBAL $G_false, $sess; + $doexit = FALSE; $shm = FALSE; log_wr("TABLE_IDX ".FTOK_PATH."/table".$table_idx); - if (($tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) { - echo "FTOK FAILED"; - exit; - } do { - // if (shmchk_exists($tok) == FALSE) - if (locshm_exists($tok) == FALSE) + if (($tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) { + log_main("ftok failed"); + $doexit = TRUE; break; + } - if (($shm = shm_attach($tok, BRISKIN5_SHM_DIMS)) == FALSE) + if (($shm_sz = sharedmem_sz($tok)) == -1) { + log_main("shmop_open failed"); + break; + } + + if (($shm = shm_attach($tok, $shm_sz)) == FALSE) break; if (($bri = @shm_get_var($shm, $tok)) == FALSE) @@ -159,15 +167,55 @@ class Briskin5 { shm_detach($shm); log_wr("briskin5 load_data failed"); + if ($doexit) + exit(); return ($G_false); } + function save_data(&$bri) { GLOBAL $sess; + $ret = FALSE; + $shm = FALSE; + + log_main("SAVE BRISKIN5 DATA"); + + if (!isset($bri->tok)) + return (FALSE); + + while ($bri->shm_sz < BRISKIN5_SHM_MAX) { + if (($shm = shm_attach($bri->tok, $bri->shm_sz)) == FALSE) + break; + + // log_only("PUT_VAR DI ".strlen(serialize($room))); + if (@shm_put_var($shm, $bri->tok, $bri) != FALSE) { + shm_detach($shm); + return (TRUE); + } + if (shm_remove($shm) === FALSE) { + log_only("REMOVE FALLITA"); + break; + } + shm_detach($shm); + $bri->shm_sz += BRISKIN5_SHM_DLT; + } + + if ($shm) + shm_detach($shm); + + return ($ret); + } + + + + function save_data_orig(&$bri) + { + GLOBAL $sess; + $ret = FALSE; $shm = FALSE; $isacq = FALSE; @@ -206,25 +254,19 @@ class Briskin5 { $ret = FALSE; $shm = FALSE; - $isacq = FALSE; - log_main("DESTROY BRISKIN5 DATA"); - do { - $isacq = TRUE; - log_main("DESTROY2 BRISKIN5 DATA"); if (($tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) break; - if (($shm = shm_attach($tok, BRISKIN5_SHM_DIMS)) === FALSE) + if (($shm = @shmop_open($tok, 'a', 0, 0)) == FALSE) break; - if (shm_remove($shm) === FALSE) { - log_only("REMOVE FALLITA ".strlen(serialize($bri))); - log_only(serialize($bri)); + if (shmop_delete($shm) == 0) { + log_only("REMOVE FALLITA "); break; } -- 2.17.1 From c14163f1c08c65ecc8f1c4ce9d7c7244a1526a51 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 19 Mar 2008 08:40:09 +0000 Subject: [PATCH 06/16] fixed buggy optimization --- web/Obj/brisk.phh | 2 +- web/briskin5/index_rd.php | 4 ++++ web/index_rd.php | 17 ++++++++++------- web/index_wr.php | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 9497600..84176bb 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -61,7 +61,7 @@ define(BRISK_SINGLE_SESS, ""); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "spawn-0.9.3"; +$G_brisk_version = "spawn-0.10.1"; $root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index fddb5a2..234e7b4 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -177,6 +177,10 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su } else { log_rd2("TRANS NON ATTIVATO"); + while (array_pop($user->comm) != NULL); + // $user->step_inc(COMM_N + 1); + + Briskin5::save_data($bri); Briskin5::unlock_data($sem); ignore_user_abort(FALSE); } diff --git a/web/index_rd.php b/web/index_rd.php index 51986e1..3f57f2d 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -174,9 +174,16 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su ignore_user_abort(FALSE); } else { - log_rd2("TRANS NON ATTIVATO"); - Room::unlock_data($sem); - ignore_user_abort(FALSE); + log_rd2("TRANS NON ATTIVATO, clean del comm array"); + while (($el = array_pop($user->comm)) != NULL) { + log_rd2("clean element [".$el."]"); + } + // $user->step_inc(COMM_N + 1); + Room::save_data($room); + // $new_step = $user->step; + + Room::unlock_data($sem); + ignore_user_abort(FALSE); } } @@ -188,10 +195,6 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $ret .= show_room(&$room, $user->step, &$user); // TODO uncomment and test - // while (array_pop($user->comm) != NULL); - // $new_step = -1; - // $user->step_inc(COMM_N + 1); - // Room::save_data($room); /* NOTE the sets went common */ $new_stat = $user->stat; $new_subst = $user->subst; diff --git a/web/index_wr.php b/web/index_wr.php index c80396d..b3abbdb 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -56,7 +56,7 @@ $argz = explode('|', $mesg); log_wr('POSTSPLIT: '.$argz[0]); if ($argz[0] == 'shutdown') { - log_auth($user_cur->sess, "Shutdown session."); + log_auth($user->sess, "Shutdown session."); $tmp_sess = $user->sess; $user->sess = ""; step_unproxy($tmp_sess); -- 2.17.1 From a6d70a024c7ad3599d319bb1a7c94d6c366303b4 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 20 Mar 2008 06:30:34 +0000 Subject: [PATCH 07/16] add critical log and check for unrecoverable join --- web/Obj/brisk.phh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 84176bb..bc2162c 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2,7 +2,7 @@ /* * brisk - brisk.phh * - * Copyright (C) 2006-2007 matteo.nastasi@milug.org + * Copyright (C) 2006-2008 matteo.nastasi@milug.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,6 +51,7 @@ define(DBG_LOCK, 0x0040); define(DBG_WRIT, 0x0080); define(DBG_LOAD, 0x0100); define(DBG_AUTH, 0x0200); +define(DBG_CRIT, 0x0400); define(BRISK_DEBUG, 0); @@ -61,7 +62,7 @@ define(BRISK_SINGLE_SESS, ""); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "spawn-0.10.1"; +$G_brisk_version = "spawn-0.10.2"; $root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); @@ -777,14 +778,14 @@ class Room { } } // else if (($bri = &Briskin5::load_data($table_idx)) != FALSE) { else if ($no_recovery == FALSE) { - log_main("ERROR: table ".$table_idx." unrecoverable join"); + log_crit("ERROR: table ".$table_idx." unrecoverable join"); for ($i = 0 ; $i < $table_cur->player_n ; $i++) { $user_cur = &$this->user[$table_cur->player[$i]]; $user_cur->subst = "shutdowner"; $user_cur->step_inc(); - $ret = sprintf('stat = "%s"; subst = "%s";', $cur_user->stat, $cur_user->subst); + $ret = sprintf('stat = "%s"; subst = "%s";', $user_cur->stat, $user_cur->subst); $ret .= "gst.st = ".($user_cur->step+1)."; "; $ret .= show_notify("
I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.

Torni in piedi.

", 2000, "Chiudi.", 400, 110); $user_cur->comm[$user_cur->step % COMM_N] = $ret; @@ -1004,7 +1005,8 @@ class Room { if ($tab_idx < $user_tab_n) { log_main("PRE show_room username: ".$user_cur->name." STEP: ".$user_cur->step); - while (array_pop($user_cur->comm) != NULL); + if ($trans_delta == 0) + while (array_pop($user_cur->comm) != NULL); $user_cur->trans_step = $user_cur->step + 1 + $trans_delta; $user_cur->comm[$user_cur->step % COMM_N] = ""; @@ -1471,6 +1473,26 @@ function log_only2($log) { } } +function log_crit($log) { + GLOBAL $sess; + + if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_CRIT) == 0) + return; + + if (isset($sess) == FALSE) + $ssess = "XXXX"; + else + $ssess = $sess; + + if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_CRIT) == 0) + return; + + if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) { + fwrite($fp, sprintf("CRIT: [%s] [%s]\n", $ssess, $log)); + fclose($fp); + } +} + function log_only($log) { GLOBAL $sess; -- 2.17.1 From e8dc1380509c5fe947b8be3ad44afc671515f871 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 20 Mar 2008 06:36:45 +0000 Subject: [PATCH 08/16] minor --- web/briskin5/Obj/briskin5.phh | 45 ++++------------------------------- web/index_rd.php | 12 +++++----- 2 files changed, 11 insertions(+), 46 deletions(-) diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 024e8cd..1ad1937 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -2,9 +2,9 @@ define(BRISKIN5_PLAYERS_N, 3); define(BRISKIN5_MAX_PLAYERS, BRISKIN5_PLAYERS_N); // define(BRISKIN5_SHM_MIN, (50000 * BRISKIN5_MAX_PLAYERS)); -define(BRISKIN5_SHM_MIN, 10000); +define(BRISKIN5_SHM_MIN, 32768); define(BRISKIN5_SHM_MAX, (BRISKIN5_SHM_MIN + 1048576)); -define(BRISKIN5_SHM_DLT, 65536); +define(BRISKIN5_SHM_DLT, 32768); class Briskin5 { var $user; @@ -191,7 +191,6 @@ class Briskin5 { if (($shm = shm_attach($bri->tok, $bri->shm_sz)) == FALSE) break; - // log_only("PUT_VAR DI ".strlen(serialize($room))); if (@shm_put_var($shm, $bri->tok, $bri) != FALSE) { shm_detach($shm); return (TRUE); @@ -204,6 +203,8 @@ class Briskin5 { $bri->shm_sz += BRISKIN5_SHM_DLT; } + log_crit("save data failed!"); + if ($shm) shm_detach($shm); @@ -212,42 +213,6 @@ class Briskin5 { - function save_data_orig(&$bri) - { - GLOBAL $sess; - - $ret = FALSE; - $shm = FALSE; - $isacq = FALSE; - - log_main("SAVE BRISKIN5 DATA"); - // var_dump($bri); - - if (!isset($bri->tok)) - return (FALSE); - - do { - $isacq = TRUE; - - if (($shm = shm_attach($bri->tok, BRISKIN5_SHM_DIMS)) == FALSE) - break; - - // log_only("PUT_VAR DI ".strlen(serialize($bri))); - if (shm_put_var($shm, $bri->tok, $bri) == FALSE) { - log_only("PUT_VAR FALLITA ".strlen(serialize($bri))); - log_only(serialize($bri)); - break; - } - // log_main("QUI CI ARRIVA [".$bri->user[0]->name."]"); - $ret = TRUE; - } while (0); - - if ($shm) - shm_detach($shm); - - return ($ret); - } - function destroy_data($table_idx) { GLOBAL $sess; @@ -495,4 +460,4 @@ function locshm_exists($tok) } -?> \ No newline at end of file +?> diff --git a/web/index_rd.php b/web/index_rd.php index 3f57f2d..6c636b8 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -175,13 +175,13 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su } else { log_rd2("TRANS NON ATTIVATO, clean del comm array"); - while (($el = array_pop($user->comm)) != NULL) { - log_rd2("clean element [".$el."]"); + while (($el = array_pop($user->comm)) != NULL) { + log_rd2("clean element [".$el."]"); } - // $user->step_inc(COMM_N + 1); - Room::save_data($room); - // $new_step = $user->step; - + // $user->step_inc(COMM_N + 1); + Room::save_data($room); + // $new_step = $user->step; + Room::unlock_data($sem); ignore_user_abort(FALSE); } -- 2.17.1 From 64c7d34242c417a2a430534717ad2b3850e27602 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 20 Mar 2008 08:33:09 +0000 Subject: [PATCH 09/16] disabled comm flush optimization --- web/Obj/brisk.phh | 7 ++++--- web/briskin5/index_rd.php | 8 +++++--- web/index_rd.php | 16 +++++++++------- web/index_wr.php | 6 ++++-- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index bc2162c..04d6483 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -62,7 +62,7 @@ define(BRISK_SINGLE_SESS, ""); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "spawn-0.10.2"; +$G_brisk_version = "spawn-0.10.3"; $root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); @@ -1005,8 +1005,9 @@ class Room { if ($tab_idx < $user_tab_n) { log_main("PRE show_room username: ".$user_cur->name." STEP: ".$user_cur->step); - if ($trans_delta == 0) - while (array_pop($user_cur->comm) != NULL); +// ARRAY_POP DISABLED +// if ($trans_delta == 0) +// while (array_pop($user_cur->comm) != NULL); $user_cur->trans_step = $user_cur->step + 1 + $trans_delta; $user_cur->comm[$user_cur->step % COMM_N] = ""; diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index 234e7b4..4bdb51f 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -177,10 +177,12 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su } else { log_rd2("TRANS NON ATTIVATO"); - while (array_pop($user->comm) != NULL); - // $user->step_inc(COMM_N + 1); - Briskin5::save_data($bri); +// ARRAY_POP DISABLED +// while (array_pop($user->comm) != NULL); +// // $user->step_inc(COMM_N + 1); +// Briskin5::save_data($bri); + Briskin5::unlock_data($sem); ignore_user_abort(FALSE); } diff --git a/web/index_rd.php b/web/index_rd.php index 6c636b8..526ca34 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -174,13 +174,15 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su ignore_user_abort(FALSE); } else { - log_rd2("TRANS NON ATTIVATO, clean del comm array"); - while (($el = array_pop($user->comm)) != NULL) { - log_rd2("clean element [".$el."]"); - } - // $user->step_inc(COMM_N + 1); - Room::save_data($room); - // $new_step = $user->step; + log_rd2("TRANS NON ATTIVATO"); +// ARRAY_POP DISABLED +// log_rd2("TRANS NON ATTIVATO, clean del comm array"); +// while (($el = array_pop($user->comm)) != NULL) { +// log_rd2("clean element [".$el."]"); +// } +// // $user->step_inc(COMM_N + 1); +// Room::save_data($room); +// // $new_step = $user->step; Room::unlock_data($sem); ignore_user_abort(FALSE); diff --git a/web/index_wr.php b/web/index_wr.php index b3abbdb..808b020 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -190,8 +190,10 @@ else if ($user->stat == 'room') { log_wr("Pre if!"); - // CHECK - while (array_pop($user_cur->comm) != NULL); +// ARRAY_POP DISABLED +// // CHECK +// while (array_pop($user_cur->comm) != NULL); + $ret = ""; $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/index.php");|', $user_cur->step+1, $table_idx, $table_token); -- 2.17.1 From 2ae8dac72522528be1c05fea5de272555d5330cf Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sat, 22 Mar 2008 12:32:35 +0000 Subject: [PATCH 10/16] speed doubled in index_rd.php and flush of command when the table start --- web/briskin5/index_rd.php | 4 ++-- web/index_rd.php | 4 ++-- web/index_wr.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index 4bdb51f..d32d36c 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -318,8 +318,8 @@ for ($i = 0 ; time() < $endtime ; $i++) { $old_subst = $subst; $old_step = $step; // log_rd("POST MAIN ".$step);; - usleep(400000); - if (($i % 5) == 0) { + usleep(200000); + if (($i % 10) == 0) { // log_rd2("TIME: ".time()); echo '_'; flush(); diff --git a/web/index_rd.php b/web/index_rd.php index 526ca34..288415c 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -322,8 +322,8 @@ for ($i = 0 ; time() < $endtime ; $i++) { $old_subst = $subst; $old_step = $step; // log_rd("POST MAIN ".$step);; - usleep(400000); - if (($i % 5) == 0) { + usleep(200000); + if (($i % 10) == 0) { // log_rd2("TIME: ".time()); echo '_'; flush(); diff --git a/web/index_wr.php b/web/index_wr.php index 808b020..ea364cd 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -192,7 +192,7 @@ else if ($user->stat == 'room') { // ARRAY_POP DISABLED // // CHECK -// while (array_pop($user_cur->comm) != NULL); + while (array_pop($user_cur->comm) != NULL); $ret = ""; $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/index.php");|', $user_cur->step+1, $table_idx, $table_token); -- 2.17.1 From 6f8bd8946cf2966f150fa43301a689ebf47cebb4 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sat, 22 Mar 2008 12:43:57 +0000 Subject: [PATCH 11/16] substituted with bg_spawn2.jpg --- web/brisk.css | 2 +- web/preload_img.js | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/web/brisk.css b/web/brisk.css index 75bcf7e..e44f8a9 100644 --- a/web/brisk.css +++ b/web/brisk.css @@ -21,7 +21,7 @@ */ body { - background-image: url('img/bg_spawn.jpg'); + background-image: url('img/bg_spawn2.jpg'); background-color: #fafafa; background-repeat: no-repeat; background-position: top center; diff --git a/web/preload_img.js b/web/preload_img.js index b332d01..aa68580 100644 --- a/web/preload_img.js +++ b/web/preload_img.js @@ -1,7 +1,7 @@ var g_preload_img_arr = new Array( "briskin5/img/brisk_table_sand0.jpg", "briskin5/img/brisk_table_sand4.jpg", "briskin5/img/brisk_table_sand1.jpg", "briskin5/img/brisk_table_sand3.jpg", - "briskin5/img/brisk_table_sand2.jpg", "img/bg_spawn.jpg", + "briskin5/img/brisk_table_sand2.jpg", "img/bg_spawn2.jpg", "briskin5/img/brisk_caller_sand4.png", "briskin5/img/brisk_caller_sand0.png", "briskin5/img/brisk_caller_sand2.png", "briskin5/img/brisk_caller_sand1.png", "briskin5/img/brisk_caller_sand3.png", "briskin5/img/33_ea.png", @@ -90,26 +90,26 @@ var g_preload_img_arr = new Array( "briskin5/img/exitlock0y.png", "img/brisk_start.png", "img/noimg.png", "img/brisk_ico.png"); var g_preload_imgsz_arr = new Array( - "5.3", "10.6", "15.9", "21.2", "26.5", "28.8", "30.5", "32.2", - "34.0", "35.7", "37.4", "38.0", "38.5", "39.1", "39.6", "40.2", - "40.7", "41.2", "41.8", "42.3", "42.9", "43.4", "43.9", "44.4", - "45.0", "45.5", "46.0", "46.5", "47.1", "47.6", "48.1", "48.6", - "49.1", "49.6", "50.1", "50.6", "51.1", "51.6", "52.1", "52.6", - "53.1", "53.6", "54.1", "54.6", "55.1", "55.6", "56.1", "56.6", - "57.1", "57.6", "58.1", "58.6", "59.1", "59.6", "60.1", "60.6", - "61.0", "61.5", "62.0", "62.5", "62.9", "63.4", "63.9", "64.4", - "64.8", "65.3", "65.8", "66.2", "66.7", "67.2", "67.6", "68.1", - "68.5", "69.0", "69.5", "69.9", "70.4", "70.8", "71.3", "71.8", - "72.2", "72.7", "73.1", "73.6", "74.0", "74.5", "74.9", "75.4", - "75.8", "76.3", "76.7", "77.2", "77.6", "78.0", "78.5", "78.9", - "79.3", "79.7", "80.2", "80.6", "81.0", "81.4", "81.8", "82.2", - "82.7", "83.1", "83.5", "83.9", "84.3", "84.7", "85.1", "85.5", - "85.9", "86.3", "86.7", "87.1", "87.5", "87.9", "88.3", "88.7", - "89.1", "89.5", "89.8", "90.2", "90.6", "91.0", "91.4", "91.8", - "92.2", "92.5", "92.9", "93.3", "93.6", "94.0", "94.4", "94.6", - "94.9", "95.0", "95.2", "95.4", "95.6", "95.8", "95.9", "96.1", - "96.3", "96.4", "96.6", "96.7", "96.9", "97.0", "97.2", "97.3", - "97.4", "97.6", "97.7", "97.8", "98.0", "98.1", "98.2", "98.3", - "98.4", "98.6", "98.7", "98.8", "98.9", "99.0", "99.1", "99.2", + "5.2", "10.5", "15.8", "21.1", "26.4", "29.2", "30.9", "32.6", + "34.3", "36.1", "37.8", "38.3", "38.9", "39.4", "40.0", "40.5", + "41.1", "41.6", "42.1", "42.7", "43.2", "43.7", "44.2", "44.8", + "45.3", "45.8", "46.3", "46.9", "47.4", "47.9", "48.4", "48.9", + "49.4", "49.9", "50.4", "50.9", "51.4", "51.9", "52.4", "52.9", + "53.4", "53.9", "54.4", "54.9", "55.4", "55.9", "56.4", "56.9", + "57.4", "57.9", "58.4", "58.9", "59.3", "59.8", "60.3", "60.8", + "61.3", "61.7", "62.2", "62.7", "63.2", "63.6", "64.1", "64.6", + "65.0", "65.5", "66.0", "66.4", "66.9", "67.3", "67.8", "68.3", + "68.7", "69.2", "69.6", "70.1", "70.6", "71.0", "71.5", "71.9", + "72.4", "72.8", "73.3", "73.7", "74.2", "74.6", "75.1", "75.5", + "76.0", "76.4", "76.9", "77.3", "77.7", "78.2", "78.6", "79.0", + "79.4", "79.9", "80.3", "80.7", "81.1", "81.5", "81.9", "82.4", + "82.8", "83.2", "83.6", "84.0", "84.4", "84.8", "85.2", "85.6", + "86.0", "86.4", "86.8", "87.2", "87.6", "88.0", "88.3", "88.7", + "89.1", "89.5", "89.9", "90.3", "90.7", "91.1", "91.4", "91.8", + "92.2", "92.6", "92.9", "93.3", "93.7", "94.0", "94.4", "94.7", + "94.9", "95.1", "95.3", "95.5", "95.6", "95.8", "96.0", "96.1", + "96.3", "96.5", "96.6", "96.8", "96.9", "97.0", "97.2", "97.3", + "97.5", "97.6", "97.7", "97.8", "98.0", "98.1", "98.2", "98.3", + "98.5", "98.6", "98.7", "98.8", "98.9", "99.0", "99.1", "99.2", "99.2", "99.3", "99.4", "99.5", "99.5", "99.6", "99.7", "99.7", "99.8", "99.9", "99.9", "100.0"); -- 2.17.1 From 28d6c18063a40898e84cead2070dc8cfb30f7875 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 23 Mar 2008 08:59:53 +0000 Subject: [PATCH 12/16] comm to 18 elements --- web/Obj/brisk.phh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 04d6483..35b8ddc 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -30,7 +30,7 @@ define(SHM_DIMS_MIN, (50000 + 10000 * TABLES_N + 15000 * MAX_PLAYERS)); define(SHM_DIMS_MAX, SHM_DIMS_MIN + 1048576); define(SHM_DIMS_DLT, 65536); -define(COMM_N, 12); +define(COMM_N, 18); define(COMM_GEN_N, 50); define(SESS_LEN, 13); define(STREAM_TIMEOUT, 20); -- 2.17.1 From e237c587f30535a051593c11baeee82fd21edd4f Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 23 Mar 2008 09:04:48 +0000 Subject: [PATCH 13/16] beta 2 --- web/Obj/brisk.phh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 35b8ddc..e39c6df 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -62,9 +62,9 @@ define(BRISK_SINGLE_SESS, ""); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "spawn-0.10.3"; +$G_brisk_version = "spawn-0.10.4"; -$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta.', +$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta2.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); $table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non può risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.'); -- 2.17.1 From 6a6c26cd9a2ba2f3782116c69c017dd3c50c864e Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 23 Mar 2008 12:13:06 +0000 Subject: [PATCH 14/16] factorized user reset (and comm array clean added) --- web/Obj/brisk.phh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index e39c6df..e3dd54b 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -643,6 +643,16 @@ class User { return (FALSE); } + + function reset() { + $tmp_sess = $this->sess; + $this->sess = ""; + step_unproxy($tmp_sess); + $this->name = ""; + while (array_pop($this->comm) != NULL); + $this->step = 0; + $this->the_end = FALSE; + } } // end class User @@ -818,12 +828,16 @@ class Room { if ($user_cur->stat == 'table' || $user_cur->stat == 'room') { log_auth($user_cur->sess, "Autologout session."); + $user_cur->reset(); + /* factorized with ->reset() $tmp_sess = $user_cur->sess; $user_cur->sess = ""; step_unproxy($tmp_sess); $user_cur->name = ""; + while (array_pop($user_cur->comm) != NULL); $user_cur->step = 0; $user_cur->the_end = FALSE; + */ log_rd2("AUTO LOGOUT."); if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table') -- 2.17.1 From ed1760b4812684de57aa109c2b03f16a33476878 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 23 Mar 2008 12:13:06 +0000 Subject: [PATCH 15/16] factorized user reset (and comm array clean added) --- web/Obj/brisk.phh | 2 +- web/index_rd.php | 9 +++++++-- web/index_wr.php | 8 +++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index e3dd54b..62b7cb1 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -62,7 +62,7 @@ define(BRISK_SINGLE_SESS, ""); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "spawn-0.10.4"; +$G_brisk_version = "spawn-0.10.5"; $root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': dimensionamento dinamico dell\'area dati e ottimizzazione della stessa, versione beta2.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); diff --git a/web/index_rd.php b/web/index_rd.php index 288415c..cc30e3e 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -248,13 +248,18 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su if ($user->the_end == TRUE) { log_rd2("LOGOUT BYE BYE!!"); log_auth($user->sess, "Explicit logout."); + + $user->reset(); + /* factorized with ->reset() $tmp_sess = $user->sess; $user->sess = ""; step_unproxy($tmp_sess); - $user->name = ""; + while (array_pop($user->comm) != NULL); + $user->step = 0; $user->the_end = FALSE; - + */ + if ($user->subst == 'sitdown') { log_load("ROOM WAKEUP"); $room->room_wakeup(&$user); diff --git a/web/index_wr.php b/web/index_wr.php index ea364cd..d7ccac2 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -57,12 +57,18 @@ log_wr('POSTSPLIT: '.$argz[0]); if ($argz[0] == 'shutdown') { log_auth($user->sess, "Shutdown session."); + + $user->reset(); + /* factorized with ->reset() $tmp_sess = $user->sess; $user->sess = ""; step_unproxy($tmp_sess); $user->name = ""; + while (array_pop($user->comm) != NULL); + $user->step = 0; $user->the_end = FALSE; - + */ + log_rd2("AUTO LOGOUT."); if ($user->subst == 'sitdown' || $user->stat == 'table') $room->room_wakeup(&$user); -- 2.17.1 From 408f27514f5af91523b71c284cff0b292865e867 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 23 Mar 2008 15:44:20 +0000 Subject: [PATCH 16/16] add nobohide class for img --- web/brisk.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/brisk.css b/web/brisk.css index e44f8a9..cb528dc 100644 --- a/web/brisk.css +++ b/web/brisk.css @@ -55,6 +55,13 @@ img.nobo { margin: auto; } +img.nobohide { + position: absolute; + border-width: 0px; + visibility: hidden; + z-index: 12; +} + .notify { border-style: solid; border-width: 1px; -- 2.17.1