mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-02 08:13:10 +00:00
Fixed RCON non-blocking sockets
This commit is contained in:
parent
33bd66c1da
commit
de5be4168d
@ -48,7 +48,7 @@ class RCON{
|
|||||||
console("[ERROR] RCON can't be started: ".socket_strerror(socket_last_error()));
|
console("[ERROR] RCON can't be started: ".socket_strerror(socket_last_error()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@socket_set_nonblock($this->socket);
|
@socket_set_block($this->socket);
|
||||||
for($n = 0; $n < $this->threads; ++$n){
|
for($n = 0; $n < $this->threads; ++$n){
|
||||||
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
|
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
|
||||||
}
|
}
|
||||||
@ -139,6 +139,10 @@ class RCONInstance extends Thread{
|
|||||||
public function run(){
|
public function run(){
|
||||||
while($this->stop !== true){
|
while($this->stop !== true){
|
||||||
usleep(1);
|
usleep(1);
|
||||||
|
$r = array($socket = $this->socket);
|
||||||
|
$w = null;
|
||||||
|
$e = null;
|
||||||
|
if(socket_select($r, $w, $e, 0) === 1){
|
||||||
if(($client = socket_accept($this->socket)) !== false){
|
if(($client = socket_accept($this->socket)) !== false){
|
||||||
socket_set_block($client);
|
socket_set_block($client);
|
||||||
socket_set_option($client, SOL_SOCKET, SO_KEEPALIVE, 1);
|
socket_set_option($client, SOL_SOCKET, SO_KEEPALIVE, 1);
|
||||||
@ -156,6 +160,7 @@ class RCONInstance extends Thread{
|
|||||||
@socket_close($client);
|
@socket_close($client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for($n = 0; $n < $this->maxClients; ++$n){
|
for($n = 0; $n < $this->maxClients; ++$n){
|
||||||
$client = &$this->{"client".$n};
|
$client = &$this->{"client".$n};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user