mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +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
|
||||
*/
|
||||
public function shutdown(){
|
||||
$this->shutdown = true;
|
||||
$this->notify();
|
||||
$this->synchronized(function() : void{
|
||||
$this->shutdown = true;
|
||||
$this->notify();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -368,7 +370,9 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
while(!$this->shutdown){
|
||||
$this->writeLogStream($logResource);
|
||||
$this->synchronized(function() : void{
|
||||
$this->wait();
|
||||
if(!$this->shutdown){
|
||||
$this->wait();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user