From: Matteo Nastasi (mop) Date: Wed, 22 Jan 2014 07:12:27 +0000 (+0100) Subject: methods and logic to manage static Brisk attrib sess_cur added X-Git-Tag: v4.12.4~2 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=059f6fcca909267802697e22ac7c8b701b9ed14e;p=brisk.git methods and logic to manage static Brisk attrib sess_cur added --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index dbc5995..1368516 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -845,6 +845,8 @@ class Brisk var $delay_mgr; + public static $sess_cur; + function Brisk($crystal_filename) { $this->crystal_filename = $crystal_filename; $this->user = array(); @@ -876,6 +878,8 @@ class Brisk $this->shm_sz = SHM_DIMS_MIN; $this->delay_mgr = new Delay_Manager(1.5); + + static::$sess_cur = FALSE; } function garbage_manager($force) @@ -2462,6 +2466,7 @@ class Brisk break; } + $this->sess_cur_set($user->sess); // close a previous opened index_read_ifra socket, if exists if (($prev = $user->rd_socket_get()) != NULL) { $s_a_p->socks_unset($user->rd_socket_get()); @@ -2542,7 +2547,15 @@ class Brisk } return NULL; } + function sess_cur_set($sess) + { + static::$sess_cur = $sess; + } + static function sess_cur_get() + { + return(static::$sess_cur); + } } // end class Brisk function make_seed() @@ -2580,11 +2593,12 @@ function trace_ftok($id, $add) function log_mop($step, $log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_LMOP) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2606,11 +2620,12 @@ function log_mop($step, $log) function log_only2($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_ONL2) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2631,11 +2646,12 @@ function log_only2($log) function log_crit($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_CRIT) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2656,11 +2672,12 @@ function log_crit($log) function log_only($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_ONLY) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2681,11 +2698,12 @@ function log_only($log) function log_main($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_MAIN) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2706,11 +2724,12 @@ function log_main($log) function log_rd($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_READ) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2731,11 +2750,12 @@ function log_rd($log) function log_rd2($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_REA2) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2757,11 +2777,12 @@ function log_rd2($log) function log_send($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_SEND) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2782,11 +2803,12 @@ function log_send($log) function log_lock($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_LOCK) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2807,11 +2829,12 @@ function log_lock($log) function log_wr($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_WRIT) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2832,11 +2855,12 @@ function log_wr($log) function log_load($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_LOAD) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else @@ -2877,11 +2901,12 @@ function log_auth($sess, $log) function log_shme($log) { - GLOBAL $sess, $PHP_SELF; + GLOBAL $PHP_SELF; if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_SHME) == 0) return; + $sess = Brisk::sess_cur_get(); if (isset($sess) == FALSE) $ssess = "XXXX"; else diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index cb10643..27ed4c4 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -626,6 +626,7 @@ class Sac_a_push { $this->main_loop = TRUE; while ($this->main_loop) { + $this->app->sess_cur_set(FALSE); $this->curtime = time(); fprintf(STDERR, "IN LOOP: Current opened: %d pending_pages: %d\n", count($this->socks), count($this->pending_pages)); diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 94d0788..f51b303 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -1151,6 +1151,7 @@ class Bin5_user extends User { class Bin5 { static $delta_t = array(); + var $brisk;// room object reference var $user; var $table; @@ -1178,9 +1179,9 @@ class Bin5 { exit; } + $this->brisk = $brisk; $user = $brisk->user; $table = $brisk->table[$table_idx]; - log_wr("Bin5 constructor"); for ($i = 0 ; $i < $table->player_n ; $i++) { @@ -1520,6 +1521,8 @@ class Bin5 { return TRUE; break; } + $bri->brisk->sess_cur_set($user->sess); + // close a previous opened index_read_ifra socket, if exists if (($prev = $user->rd_socket_get()) != NULL) { $s_a_p->socks_unset($user->rd_socket_get()); diff --git a/web/briskin5/index_wr.php b/web/briskin5/index_wr.php index 491ee9d..ef9dfda 100644 --- a/web/briskin5/index_wr.php +++ b/web/briskin5/index_wr.php @@ -76,7 +76,7 @@ function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie) log_wr("Get User Error"); return FALSE; } - + $bin5->brisk->sess_cur_set($user->sess); if (array_search($user->ip, $G_black_list) !== FALSE) { // TODO: waiting async 5 sec before close return (FALSE); diff --git a/web/index.php b/web/index.php index 9301b37..294234c 100644 --- a/web/index.php +++ b/web/index.php @@ -293,6 +293,7 @@ function index_main(&$brisk, $transp_type, &$header_out, $addr, $get, $post, $co $brisk->garbage_manager(TRUE); log_main("post garbage_manager"); if (($user = &$brisk->get_user($sess, &$idx)) != FALSE) { + $brisk->sess_cur_set($user->sess); log_main("user stat: ".$user->stat); if ($user->stat == "table") { $cookies = new Cookies(); @@ -318,6 +319,7 @@ function index_main(&$brisk, $transp_type, &$header_out, $addr, $get, $post, $co $ipv4addr = addrtoipv4($addr); if (($user = $brisk->add_user(&$sess, &$idx, $name, $pass_private, $ipv4addr, $cookie)) != FALSE) { + $brisk->sess_cur_set($user->sess); $ACTION = "room"; if ($idx < 0) { $idx = -$idx - 1; diff --git a/web/index_wr.php b/web/index_wr.php index 9360c4b..4f1fae3 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -197,6 +197,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) return TRUE; } // end if (($user = $brisk->get_user($sess, ... == FALSE) { + $brisk->sess_cur_set($user->sess); $argz = explode('|', xcapemesg($mesg)); log_wr('POSTSPLIT: '.$argz[0]);