From: Matteo Nastasi (mop) Date: Mon, 16 May 2011 06:25:32 +0000 (+0200) Subject: load_data return allways, all exit() calls removed, all load_data calls are protected X-Git-Tag: 3.5.5~12 X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=8fe1e432c4661ebf186026f920d778d37dbe0953;p=brisk.git load_data return allways, all exit() calls removed, all load_data calls are protected --- diff --git a/web/Obj/auth.phh b/web/Obj/auth.phh index c96a090..8e74ffd 100644 --- a/web/Obj/auth.phh +++ b/web/Obj/auth.phh @@ -165,11 +165,9 @@ class Challenges { function load_data() { GLOBAL $sess; - $doexit = FALSE; do { if (($tok = @ftok(FTOK_PATH."/challenges", "B")) == -1) { log_main("ftok failed"); - $doexit = TRUE; break; } @@ -204,9 +202,6 @@ class Challenges { return ($chals); } while (0); - if ($doexit) - exit(); - return (FALSE); } diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 0083169..2a2d9eb 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -914,11 +914,9 @@ class User { { log_main("load_data: id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); - $doexit = FALSE; do { if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { log_main("ftok failed"); - $doexit = TRUE; break; } @@ -933,7 +931,6 @@ class User { $user = @shm_get_var($shm, $tok); if ($sess != FALSE && $user->sess != $sess) { - $doexit = TRUE; break; } log_only("user == ".($user == FALSE ? "FALSE" : "TRUE")." user === ".($user === FALSE ? "FALSE" : "TRUE")." user isset ".(isset($user) ? "TRUE" : "FALSE")); @@ -973,9 +970,6 @@ class User { return ($user); } while (0); - if ($doexit) - exit(); - return (FALSE); } @@ -1116,7 +1110,7 @@ class Room { // is the end of the table if ($bri->the_end == TRUE) { - /* + /* * DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN */ log_main("garbage_manager: INSIDE THE END."); @@ -2258,12 +2252,10 @@ class Room { function load_data() { GLOBAL $sess; - $doexit = FALSE; do { if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) { log_main("ftok failed"); - $doexit = TRUE; break; } @@ -2297,7 +2289,13 @@ class Room { shm_detach($shm); for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { - $room->user[$i] = User::load_data($i, FALSE); + if (($room->user[$i] = User::load_data($i, FALSE)) == FALSE) { + log_crit("Bin5_user::load_data failed"); + break; + } + } + if ($i < MAX_PLAYERS) { + break; } } @@ -2307,9 +2305,6 @@ class Room { return ($room); } while (0); - if ($doexit) - exit(); - return (FALSE); } diff --git a/web/Obj/hardban.phh b/web/Obj/hardban.phh index 05ca8e1..1795a60 100644 --- a/web/Obj/hardban.phh +++ b/web/Obj/hardban.phh @@ -157,11 +157,10 @@ class Hardbans { function load_data() { GLOBAL $sess; - $doexit = FALSE; + do { if (($tok = @ftok(FTOK_PATH."/hardbans", "B")) == -1) { log_main("ftok failed"); - $doexit = TRUE; break; } @@ -196,9 +195,6 @@ class Hardbans { return ($hban); } while (0); - if ($doexit) - exit(); - return (FALSE); } diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 78d5766..3da1545 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -575,11 +575,9 @@ class Bin5_user extends User { { log_main("Bin5_user::load_data: tab_id [".$tab_id."] id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); - $doexit = FALSE; do { if (($tok = @ftok(FTOK_PATH."/bin5/table".$tab_id."/user".$id, "B")) == -1) { log_main("ftok failed"); - $doexit = TRUE; break; } @@ -594,7 +592,6 @@ class Bin5_user extends User { $user = @shm_get_var($shm, $tok); if ($sess != FALSE && $user->sess != $sess) { - $doexit = TRUE; break; } log_only("user == ".($user == FALSE ? "FALSE" : "TRUE")." user === ".($user === FALSE ? "FALSE" : "TRUE")." user isset ".(isset($user) ? "TRUE" : "FALSE")); @@ -634,8 +631,7 @@ class Bin5_user extends User { return ($user); } while (0); - if ($doexit) - exit(); + log_crit("Bin5_user::load_data:ret FALSE"); return (FALSE); } @@ -809,7 +805,6 @@ class Bin5 { // Bin5::load_data static function load_data($table_idx, $table_token = "") { - $doexit = FALSE; $shm = FALSE; log_wr("TABLE_FTOK ".FTOK_PATH."/bin5/table".$table_idx."/table"); @@ -817,7 +812,6 @@ class Bin5 { do { if (($tok = @ftok(FTOK_PATH."/bin5/table".$table_idx."/table", "B")) == -1) { log_main("ftok failed"); - $doexit = TRUE; break; } @@ -841,7 +835,13 @@ class Bin5 { shm_detach($shm); for ($i = 0 ; $i < BIN5_MAX_PLAYERS ; $i++) { - $bri->user[$i] = Bin5_user::load_data($table_idx, $i, FALSE); + if (($bri->user[$i] = Bin5_user::load_data($table_idx, $i, FALSE)) == FALSE) { + log_crit("Bin5_user::load_data failed"); + break; + } + } + if ($i < BIN5_MAX_PLAYERS) { + break; } return ($bri); @@ -851,8 +851,6 @@ class Bin5 { shm_detach($shm); log_wr("briskin5 load_data failed"); - if ($doexit) - exit(); return (FALSE); } diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index 22903a2..1800f21 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -175,7 +175,11 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su */ ignore_user_abort(TRUE); $sem = Bin5::lock_data($table_idx); - $bri = Bin5::load_data($table_idx, $table_token); + if (($bri = Bin5::load_data($table_idx, $table_token)) == FALSE) { + Bin5::unlock_data($sem); + ignore_user_abort(FALSE); + return (unrecerror()); + } $S_load_stat['R_minusone']++; /* unset the $user var to reload it from main structure */ @@ -270,7 +274,11 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su log_auth($user->sess, "Explicit logout."); $S_load_stat['R_the_end']++; - $bri = Bin5::load_data($table_idx, $table_token); + if (($bri = Bin5::load_data($table_idx, $table_token)) == FALSE) { + Bin5::unlock_data($sem); + ignore_user_abort(FALSE); + return (unrecerror()); + } unset($user); if (($user = $bri->get_user($sess, $idx)) == FALSE) { Bin5::unlock_data($sem); diff --git a/web/index.php b/web/index.php index ee4e791..90191d5 100644 --- a/web/index.php +++ b/web/index.php @@ -238,7 +238,10 @@ function main() $is_table = FALSE; $sem = Room::lock_data(); log_main("lock Room"); - $room = Room::load_data(); + if (($room = Room::load_data()) == FALSE) { + log_crit("load_data failed"); + exit(); + } $curtime = time(); /* Actions */ diff --git a/web/index_rd.php b/web/index_rd.php index d5c5d87..0850a36 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -196,7 +196,11 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su */ ignore_user_abort(TRUE); $sem = Room::lock_data(); - $room = Room::load_data(); + if (($room = Room::load_data()) == FALSE) { + Room::unlock_data($sem); + ignore_user_abort(FALSE); + return (unrecerror()); + } $S_load_stat['R_minusone']++; /* unset the $user var to reload it from main structure */ @@ -318,7 +322,12 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su log_auth($user->sess, "Explicit logout."); $S_load_stat['R_the_end']++; - $room = Room::load_data(); + if (($room = Room::load_data()) == FALSE) { + Room::unlock_data($sem); + ignore_user_abort(FALSE); + return (unrecerror()); + } + unset($user); if (($user = $room->get_user($sess, $idx)) == FALSE) { Room::unlock_data($sem);