summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorEvilSeph <evilseph@unaligned.org>2011-06-30 02:18:11 -0400
committerEvilSeph <evilseph@unaligned.org>2011-06-30 13:42:18 -0400
commit49df44ad6c4625301b32762d059936c0aeb42d25 (patch)
treedde5e2a9cdb7469a5444e952a7fdc6a7dfcf3d8c /src/main/java/org/bukkit
parent8a521ec629902255a56918d82bafb193ffa1ba54 (diff)
downloadcraftbukkit-49df44ad6c4625301b32762d059936c0aeb42d25.tar
craftbukkit-49df44ad6c4625301b32762d059936c0aeb42d25.tar.gz
craftbukkit-49df44ad6c4625301b32762d059936c0aeb42d25.tar.lz
craftbukkit-49df44ad6c4625301b32762d059936c0aeb42d25.tar.xz
craftbukkit-49df44ad6c4625301b32762d059936c0aeb42d25.zip
Possible fix for cancelled CraftScheduler tasks still running.
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index d2cd7ad0..02066909 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -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);
}