3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 04:50:06 +01:00

Possible fix for cancelled CraftScheduler tasks still running.

Dieser Commit ist enthalten in:
EvilSeph 2011-06-30 02:18:11 -04:00
Ursprung 8a521ec629
Commit 49df44ad6c

Datei anzeigen

@ -253,7 +253,11 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
} }
public void cancelTask(int taskId) { public void cancelTask(int taskId) {
syncedTasksLock.lock();
try {
synchronized (schedulerQueue) { synchronized (schedulerQueue) {
mainThreadLock.lock();
try {
Iterator<CraftTask> itr = schedulerQueue.keySet().iterator(); Iterator<CraftTask> itr = schedulerQueue.keySet().iterator();
while (itr.hasNext()) { while (itr.hasNext()) {
CraftTask current = itr.next(); CraftTask current = itr.next();
@ -261,7 +265,28 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
itr.remove(); 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); craftThreadManager.interruptTask(taskId);
} }