From d08807abaff208d585bf09c657aa989e0b68c744 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Mon, 22 Apr 2013 14:29:30 +0200 Subject: [PATCH] Added 4 RCON threads --- PocketMine-MP.php | 1 + src/API/ConsoleAPI.php | 2 +- src/functions.php | 17 +++++++++++++++++ src/utils/RCON.php | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/PocketMine-MP.php b/PocketMine-MP.php index 64da055b5..5d44186db 100644 --- a/PocketMine-MP.php +++ b/PocketMine-MP.php @@ -35,4 +35,5 @@ require_once(FILE_PATH."/src/dependencies.php"); $server = new ServerAPI(); $server->start(); +kill(getmypid()); //Fix for ConsoleAPI being blocked exit(0); \ No newline at end of file diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index 1e805ad02..1124fee84 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -54,7 +54,7 @@ class ConsoleAPI{ $this->loop->stop = true; @fclose(STDIN); $this->loop->notify(); - $this->loop->join(); + //$this->loop->join(); } public function defaultCommands($cmd, $params, $issuer, $alias){ diff --git a/src/functions.php b/src/functions.php index 2966d1307..551ece684 100644 --- a/src/functions.php +++ b/src/functions.php @@ -36,6 +36,23 @@ if(!function_exists("cli_set_process_title")){ } } +function kill($pid){ + switch(Utils::getOS()){ + case "win": + ob_start(); + passthru("%WINDIR%\\System32\\taskkill.exe /F /PID ".((int) $pid)); + ob_end_clean(); + break; + case "mac": + case "linux": + default: + ob_start(); + passthru("kill -9 ".((int) $pid)); + ob_end_clean(); + } +} + + function require_all($path, &$count = 0){ $dir = dir($path."/"); $dirs = array(); diff --git a/src/utils/RCON.php b/src/utils/RCON.php index d2e6c942c..74cdc426b 100644 --- a/src/utils/RCON.php +++ b/src/utils/RCON.php @@ -30,7 +30,7 @@ the Free Software Foundation, either version 3 of the License, or class RCON{ private $socket, $password, $workers, $threads; - public function __construct($password, $port = 19132, $threads = 1){ + public function __construct($password, $port = 19132, $threads = 4){ $this->workers = array(); $this->password = (string) $password; console("[INFO] Starting remote control listener");