Micro-optimizations

This commit is contained in:
Shoghi Cervantes
2014-10-15 10:44:01 +02:00
parent 7b7b91ea0d
commit 9b85abd75e
16 changed files with 63 additions and 68 deletions

View File

@ -59,12 +59,12 @@ class RCON{
return;
}
@socket_set_block($this->socket);
socket_set_block($this->socket);
for($n = 0; $n < $this->threads; ++$n){
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
}
@socket_getsockname($this->socket, $addr, $port);
socket_getsockname($this->socket, $addr, $port);
$this->server->getLogger()->info("RCON running on $addr:$port");
$this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, "check"]), 3);
}

View File

@ -57,7 +57,7 @@ class RCONInstance extends \Thread{
}
private function readPacket($client, &$size, &$requestID, &$packetType, &$payload){
@socket_set_nonblock($client);
socket_set_nonblock($client);
$d = socket_read($client, 4);
if($this->stop === true){
return false;
@ -66,7 +66,7 @@ class RCONInstance extends \Thread{
}elseif($d === "" or strlen($d) < 4){
return false;
}
@socket_set_block($client);
socket_set_block($client);
$size = Binary::readLInt($d);
if($size < 0 or $size > 65535){
return false;
@ -131,7 +131,7 @@ class RCONInstance extends \Thread{
continue;
}
if($payload === $this->password){
@socket_getpeername($client, $addr, $port);
socket_getpeername($client, $addr, $port);
$this->response = "[INFO] Successful Rcon connection from: /$addr:$port";
$this->synchronized(function (){
$this->wait();