From: Matteo Nastasi (mop) <nastasi@alternativeoutput.it> Date: Wed, 21 Nov 2012 18:19:24 +0000 (+0100) Subject: add dump/restore feature and set new version to 4.2.0 X-Git-Tag: v4.2.1~1 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=5251efdfad905c4ef44de1efd5c274688132a776;p=brisk.git add dump/restore feature and set new version to 4.2.0 --- diff --git a/TODO.txt b/TODO.txt index fb9ce25..15bca3b 100644 --- a/TODO.txt +++ b/TODO.txt @@ -6,23 +6,23 @@ - BUG: pari + 72 non fa 4x ma attualmente fa 3x, da correggere - BUG: some connection to the named socket fails - log_legal address fix - - save/restore database MINOR | -------+ - in the first tentative, the second works - try to be more antivirus-friendly - - centralize all '<script ...' incapsulation to allow multiple transport system. - packetize and automatize php-ancillary and apache module - into the room local step remains -1 - + - add xhr as transport layer and manage different streams better - DISABLED_TO_FIX: DNS access (perform blocking dns requests, must be fixed) DONE | ------+ + DONE - save/restore database + DONE - centralize all '<script ...' incapsulation to allow multiple transport system. DONE - BUG: access with password from 2 diff browsers the second go in strange "page not found" + in the first tentative, the second works DONE - BUG: access with password from 2 diff browsers place the first in a strict loop (the problem was a call to a static parent method instead of the overrided child method, substitute self:: with the dynamically get class::) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 4f304e4..e057839 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -140,10 +140,10 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi', $G_lng = langtolng($G_lang); $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "4.1.1"; +$G_brisk_version = "4.2.0"; /* MLANG: ALL THE INFO STRINGS IN brisk.phh */ -$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: adottato sac-a-push come motore per l\'invio dei dati in tempo reale, nuovo trasporto httpfile per explorer, tanti bug fixati.', +$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: adottato sac-a-push come motore per l\'invio dei dati in tempo reale, nuovo trasporto httpfile per explorer, tanti bug fixati, freeze su disco.', 'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ), 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: usage of reader/writer locking instead of generic exclusive locking.', 'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) ); @@ -672,46 +672,49 @@ class Table { -class Room { +class Room +{ static $delta_t; - - var $user; - var $table; - var $match; - 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(); - $this->table = array(); - $this->match = array(); - - for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { - $this->user[$i] = User::create($this, $i, "", ""); - } - - for ($i = 0 ; $i < TABLES_N ; $i++) { - $this->table[$i] = Table::create($i); - /* OLD METHOD - if ($i < 12) { - $row = ( (((int)($i / 4)) % 2) == 0 ); - $col = ($i % 2 == 0); - $this->table[$i]->auth_only = (($row && $col) || (!$row && !$col)); - } - else { - $this->table[$i]->auth_only = FALSE; - } - */ - if ($i < TABLES_AUTH_N) - $this->table[$i]->auth_only = TRUE; - else - $this->table[$i]->auth_only = FALSE; + + var $crystal_filename; + var $user; + var $table; + var $match; + var $comm; // commands for many people + var $step; // current step of the comm array + var $garbage_timeout; + var $shm_sz; + + function Room ($crystal_filename) { + $this->crystal_filename = $crystal_filename; + $this->user = array(); + $this->table = array(); + $this->match = array(); + + for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { + $this->user[$i] = User::create($this, $i, "", ""); + } + + for ($i = 0 ; $i < TABLES_N ; $i++) { + $this->table[$i] = Table::create($i); + /* OLD METHOD + if ($i < 12) { + $row = ( (((int)($i / 4)) % 2) == 0 ); + $col = ($i % 2 == 0); + $this->table[$i]->auth_only = (($row && $col) || (!$row && !$col)); + } + else { + $this->table[$i]->auth_only = FALSE; + } + */ + if ($i < TABLES_AUTH_N) + $this->table[$i]->auth_only = TRUE; + else + $this->table[$i]->auth_only = FALSE; + } + $this->garbage_timeout = 0; + $this->shm_sz = SHM_DIMS_MIN; } - $this->garbage_timeout = 0; - $this->shm_sz = SHM_DIMS_MIN; - } function garbage_manager($force) { @@ -1863,10 +1866,17 @@ class Room { } // Static functions - static function create() + static function create($crystal_filename) { - $room = new Room(); - + if (($room_ser = @file_get_contents($crystal_filename)) == FALSE || + ($room = unserialize($room_ser)) == FALSE) { + fprintf(STDERR, "NEW ROOM\n"); + $room = new Room($crystal_filename); + } + else { + fprintf(STDERR, "ROOM FROM FILE\n"); + } + return $room; } @@ -1966,7 +1976,16 @@ class Room { return (FALSE); } - + function dump_data() + { + $room_ser = serialize($this); + $room_ser_len = mb_strlen($room_ser, "ASCII"); + if (file_put_contents($this->crystal_filename, $room_ser) == $room_ser_len) { + return (TRUE); + } + + return (FALSE); + } function save_data($room) { diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 5d62a37..3f5c4c1 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -545,6 +545,14 @@ class Sac_a_push { if ($line == "reload") { require("$DOCUMENT_ROOT/Etc/".BRISK_CONF); } + else if ($line == "shutdown") { + if ($this->app->dump_data()) { + exit(0); + } + else { + exit(1); + } + } } else { $key = array_search("$sock", $this->socks); diff --git a/web/spush/brisk-spush.php b/web/spush/brisk-spush.php index af0881d..8eece0c 100755 --- a/web/spush/brisk-spush.php +++ b/web/spush/brisk-spush.php @@ -41,7 +41,7 @@ require_once($G_base."briskin5/index_wr.php"); function main() { - if (($room = Room::create()) == FALSE) { + if (($room = Room::create(LEGAL_PATH."/brisk-crystal.data")) == FALSE) { log_crit("room::create failed"); exit(1); }