mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Fixed uncaught exceptions during Task->onCancel() causing all kinds of nasty behaviour
including crashing the server on shutdown, preventing self-cancellation, and causing memory leaks
This commit is contained in:
parent
2f614c5dc2
commit
1d338bfdf9
@ -25,6 +25,7 @@ namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\event\TimingsHandler;
|
||||
use pocketmine\utils\MainLogger;
|
||||
|
||||
class TaskHandler{
|
||||
|
||||
@ -136,10 +137,15 @@ class TaskHandler{
|
||||
* Changes to this function won't be recorded on the version.
|
||||
*/
|
||||
public function cancel(){
|
||||
if(!$this->isCancelled()){
|
||||
$this->task->onCancel();
|
||||
try{
|
||||
if(!$this->isCancelled()){
|
||||
$this->task->onCancel();
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
MainLogger::getLogger()->logException($e);
|
||||
}finally{
|
||||
$this->remove();
|
||||
}
|
||||
$this->remove();
|
||||
}
|
||||
|
||||
public function remove(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user