mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 16:34:05 +00:00
Issue 1843 - RCON worker threads synchronization corrected
This commit is contained in:
parent
269a10fadd
commit
5242e87026
@ -85,11 +85,15 @@ class RCON{
|
|||||||
}elseif($this->workers[$n]->isWaiting()){
|
}elseif($this->workers[$n]->isWaiting()){
|
||||||
if($this->workers[$n]->response !== ""){
|
if($this->workers[$n]->response !== ""){
|
||||||
MainLogger::getLogger()->info($this->workers[$n]->response);
|
MainLogger::getLogger()->info($this->workers[$n]->response);
|
||||||
$this->workers[$n]->notify();
|
$this->workers[$n]->synchronized(function($thread){
|
||||||
|
$thread->notify();
|
||||||
|
}, $this->workers[$n]);
|
||||||
}else{
|
}else{
|
||||||
Server::getInstance()->dispatchCommand($response = new RemoteConsoleCommandSender(), $this->workers[$n]->cmd);
|
Server::getInstance()->dispatchCommand($response = new RemoteConsoleCommandSender(), $this->workers[$n]->cmd);
|
||||||
$this->workers[$n]->response = TextFormat::clean($response->getMessage());
|
$this->workers[$n]->response = TextFormat::clean($response->getMessage());
|
||||||
$this->workers[$n]->notify();
|
$this->workers[$n]->synchronized(function($thread){
|
||||||
|
$thread->notify();
|
||||||
|
}, $this->workers[$n]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,9 @@ class RCONInstance extends \Thread{
|
|||||||
if($payload === $this->password){
|
if($payload === $this->password){
|
||||||
@socket_getpeername($client, $addr, $port);
|
@socket_getpeername($client, $addr, $port);
|
||||||
$this->response = "[INFO] Successful Rcon connection from: /$addr:$port";
|
$this->response = "[INFO] Successful Rcon connection from: /$addr:$port";
|
||||||
$this->wait();
|
$this->synchronized(function($thread){
|
||||||
|
$thread->wait();
|
||||||
|
}, $this);
|
||||||
$this->response = "";
|
$this->response = "";
|
||||||
$this->writePacket($client, $requestID, 2, "");
|
$this->writePacket($client, $requestID, 2, "");
|
||||||
$this->{"status" . $n} = 1;
|
$this->{"status" . $n} = 1;
|
||||||
@ -150,7 +152,9 @@ class RCONInstance extends \Thread{
|
|||||||
}
|
}
|
||||||
if(strlen($payload) > 0){
|
if(strlen($payload) > 0){
|
||||||
$this->cmd = ltrim($payload);
|
$this->cmd = ltrim($payload);
|
||||||
$this->wait();
|
$this->synchronized(function($thread){
|
||||||
|
$thread->wait();
|
||||||
|
}, $this);
|
||||||
$this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->response)));
|
$this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->response)));
|
||||||
$this->response = "";
|
$this->response = "";
|
||||||
$this->cmd = "";
|
$this->cmd = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user