mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-01 07:43:03 +00:00
RakLibServer: do not try to export exceptions across threads (they might contain Threaded objects whose references get invalidated)
This commit is contained in:
parent
cc473184ac
commit
541cfee615
@ -125,7 +125,7 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
|||||||
if(!$this->rakLib->isRunning()){
|
if(!$this->rakLib->isRunning()){
|
||||||
$e = $this->rakLib->getCrashInfo();
|
$e = $this->rakLib->getCrashInfo();
|
||||||
if($e !== null){
|
if($e !== null){
|
||||||
throw $e;
|
throw new \RuntimeException("RakLib crashed: $e");
|
||||||
}
|
}
|
||||||
throw new \Exception("RakLib Thread crashed without crash information");
|
throw new \Exception("RakLib Thread crashed without crash information");
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class RakLibServer extends Thread{
|
|||||||
/** @var SleeperNotifier */
|
/** @var SleeperNotifier */
|
||||||
protected $mainThreadNotifier;
|
protected $mainThreadNotifier;
|
||||||
|
|
||||||
/** @var \Throwable|null */
|
/** @var string|null */
|
||||||
public $crashInfo = null;
|
public $crashInfo = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,22 +111,22 @@ class RakLibServer extends Thread{
|
|||||||
|
|
||||||
if($error !== null){
|
if($error !== null){
|
||||||
$this->logger->emergency("Fatal error: " . $error["message"] . " in " . $error["file"] . " on line " . $error["line"]);
|
$this->logger->emergency("Fatal error: " . $error["message"] . " in " . $error["file"] . " on line " . $error["line"]);
|
||||||
$this->setCrashInfo(new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']));
|
$this->setCrashInfo($error['message']);
|
||||||
}else{
|
}else{
|
||||||
$this->logger->emergency("RakLib shutdown unexpectedly");
|
$this->logger->emergency("RakLib shutdown unexpectedly");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCrashInfo() : ?\Throwable{
|
public function getCrashInfo() : ?string{
|
||||||
return $this->crashInfo;
|
return $this->crashInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setCrashInfo(\Throwable $e) : void{
|
private function setCrashInfo(string $info) : void{
|
||||||
$this->synchronized(function(\Throwable $e) : void{
|
$this->synchronized(function(string $info) : void{
|
||||||
$this->crashInfo = $e;
|
$this->crashInfo = $info;
|
||||||
$this->notify();
|
$this->notify();
|
||||||
}, $e);
|
}, $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function startAndWait(int $options = PTHREADS_INHERIT_NONE) : void{
|
public function startAndWait(int $options = PTHREADS_INHERIT_NONE) : void{
|
||||||
@ -136,7 +136,7 @@ class RakLibServer extends Thread{
|
|||||||
$this->wait();
|
$this->wait();
|
||||||
}
|
}
|
||||||
if($this->crashInfo !== null){
|
if($this->crashInfo !== null){
|
||||||
throw $this->crashInfo;
|
throw new \RuntimeException("RakLib failed to start: $this->crashInfo");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ class RakLibServer extends Thread{
|
|||||||
$manager->run();
|
$manager->run();
|
||||||
$this->cleanShutdown = true;
|
$this->cleanShutdown = true;
|
||||||
}catch(\Throwable $e){
|
}catch(\Throwable $e){
|
||||||
$this->setCrashInfo($e);
|
$this->setCrashInfo($e->getMessage());
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user