From ad9bfccebd7532f3283ef6cc0733a47973c9a44e Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 18 Sep 2014 08:23:48 +0200 Subject: [PATCH] reload refactored to be used in create method too and avoid code duplication --- web/Obj/brisk.phh | 30 +++++++++--------------------- web/Obj/sac-a-push.phh | 2 +- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 881e9a3..2efb2ff 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1007,18 +1007,7 @@ class Brisk function Brisk() { - // create cds - $this->cds = new Curl_de_sac(); - - // create tor_chk_cls - $tor_chk_cls = new tor_chk_cmd_cls(); - - // registrer tor_chk_cls - printf("MAIN: Register 'tor_chk_cls'\n"); - if (($this->cds->cmd_cls_register($tor_chk_cls)) == FALSE) { - fprintf(STDERR, "MAIN: 'tor_chk_cls' registration failed\n"); - exit(1); - } + $this->cds = NULL; } // constructor @@ -1028,7 +1017,7 @@ class Brisk fprintf(STDERR, "ROOM FROM FILE\n"); rename($crystal_filename, $crystal_filename.".old"); - $brisk->reload($ban_list, $black_list); + $brisk->reload(TRUE, $ban_list, $black_list); return($brisk); } @@ -1045,11 +1034,6 @@ class Brisk $thiz->ban_list = NULL; $thiz->black_list = NULL; - fprintf(STDERR, "PRE IPCLASS_UPDATE (%d, %d)\n", count($ban_list), count($black_list)); - $thiz->ipclass_update('ban_list', $ban_list); - $thiz->ipclass_update('black_list', $black_list); - fprintf(STDERR, "POST IPCLASS_UPDATE %d %d\n", count($thiz->ban_list), count($thiz->black_list)); - for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { $thiz->user[$i] = User::create($thiz, $i, "", ""); } @@ -1064,6 +1048,8 @@ class Brisk static::$sess_cur = FALSE; + $thiz->reload(TRUE, $ban_list, $black_list); + return ($thiz); } @@ -1088,15 +1074,17 @@ class Brisk } } - function reload($ban_list, $black_list) + function reload($is_first, $ban_list, $black_list) { fprintf(STDERR, "RELOAD STUFF (%d)(%d)\n", count($ban_list), count($black_list)); $this->ipclass_update("ban_list", $ban_list); $this->ipclass_update("black_list", $black_list); - $this->banned_kickoff(); - $this->garbage_manager(TRUE); + if (!$is_first) { + $this->banned_kickoff(); + $this->garbage_manager(TRUE); + } } function banned_kickoff() diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 4e88985..6ed7a0e 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -796,7 +796,7 @@ class Sac_a_push { $line = trim($buf); if ($line == "reload") { require("$DOCUMENT_ROOT/Etc/".BRISK_CONF); - $this->app->reload($G_ban_list, $G_black_list); + $this->app->reload(FALSE, $G_ban_list, $G_black_list); global_dump(); } else if ($line == "shutdown" || $line == "sd") { -- 2.17.1