mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-18 15:20:37 +01:00
Possible fix for cancelled CraftScheduler tasks still running.
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
6f94838466
commit
f7df7a7870
1 changed files with 31 additions and 6 deletions
|
@ -253,15 +253,40 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
|||
}
|
||||
|
||||
public void cancelTask(int taskId) {
|
||||
synchronized (schedulerQueue) {
|
||||
Iterator<CraftTask> itr = schedulerQueue.keySet().iterator();
|
||||
while (itr.hasNext()) {
|
||||
CraftTask current = itr.next();
|
||||
if (current.getIdNumber() == taskId) {
|
||||
itr.remove();
|
||||
syncedTasksLock.lock();
|
||||
try {
|
||||
synchronized (schedulerQueue) {
|
||||
mainThreadLock.lock();
|
||||
try {
|
||||
Iterator<CraftTask> itr = schedulerQueue.keySet().iterator();
|
||||
while (itr.hasNext()) {
|
||||
CraftTask current = itr.next();
|
||||
if (current.getIdNumber() == taskId) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
itr = mainThreadQueue.iterator();
|
||||
while (itr.hasNext()) {
|
||||
CraftTask current = itr.next();
|
||||
if (current.getIdNumber() == taskId) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
itr = syncedTasks.iterator();
|
||||
while (itr.hasNext()) {
|
||||
CraftTask current = itr.next();
|
||||
if (current.getIdNumber() == taskId) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
mainThreadLock.unlock();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
syncedTasksLock.unlock();
|
||||
}
|
||||
|
||||
craftThreadManager.interruptTask(taskId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue