Improve #2238, do not crash when an invalid/corrupt RCON stop event happens

This commit is contained in:
Shoghi Cervantes 2014-10-28 02:09:36 +01:00
parent 4299ebebcc
commit 69492474e4

View File

@ -38,7 +38,7 @@ class RCON{
private $socket;
private $password;
/** @var RCONInstance[] */
private $workers;
private $workers = [];
private $clientsPerThread;
public function __construct(Server $server, $password, $port = 19132, $interface = "0.0.0.0", $threads = 1, $clientsPerThread = 50){
@ -56,7 +56,7 @@ class RCON{
$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if($this->socket === false or !socket_bind($this->socket, $interface, (int) $port) or !socket_listen($this->socket)){
$this->server->getLogger()->critical("RCON can't be started: " . socket_strerror(socket_last_error()));
$this->threads = 0;
return;
}
socket_set_block($this->socket);