mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 06:55:29 +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\Timings;
|
||||||
use pocketmine\event\TimingsHandler;
|
use pocketmine\event\TimingsHandler;
|
||||||
|
use pocketmine\utils\MainLogger;
|
||||||
|
|
||||||
class TaskHandler{
|
class TaskHandler{
|
||||||
|
|
||||||
@ -136,10 +137,15 @@ class TaskHandler{
|
|||||||
* Changes to this function won't be recorded on the version.
|
* Changes to this function won't be recorded on the version.
|
||||||
*/
|
*/
|
||||||
public function cancel(){
|
public function cancel(){
|
||||||
if(!$this->isCancelled()){
|
try{
|
||||||
$this->task->onCancel();
|
if(!$this->isCancelled()){
|
||||||
|
$this->task->onCancel();
|
||||||
|
}
|
||||||
|
}catch(\Throwable $e){
|
||||||
|
MainLogger::getLogger()->logException($e);
|
||||||
|
}finally{
|
||||||
|
$this->remove();
|
||||||
}
|
}
|
||||||
$this->remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove(){
|
public function remove(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user