mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 12:48:32 +00:00
Fixed race condition in MainLogger shutdown
this resulted in a deadlock in https://github.com/pmmp/PocketMine-MP/runs/1831812620?check_suite_focus=true because the notify() arrived while writeLogStream() was executing. This ensures that either: - the notification will occur before the sleep, and therefore no sleeping will occur (this->shutdown = true before the wait) - the notification will arrive during the sleep.
This commit is contained in:
parent
8ef1e54e20
commit
7e3e63f342
@ -278,8 +278,10 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function shutdown(){
|
public function shutdown(){
|
||||||
|
$this->synchronized(function() : void{
|
||||||
$this->shutdown = true;
|
$this->shutdown = true;
|
||||||
$this->notify();
|
$this->notify();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -368,7 +370,9 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
while(!$this->shutdown){
|
while(!$this->shutdown){
|
||||||
$this->writeLogStream($logResource);
|
$this->writeLogStream($logResource);
|
||||||
$this->synchronized(function() : void{
|
$this->synchronized(function() : void{
|
||||||
|
if(!$this->shutdown){
|
||||||
$this->wait();
|
$this->wait();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user