From 0d12ae3f144f14494427fde098e7ebd109378964 Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 29 Dec 2011 00:29:42 +0400 Subject: [PATCH] deadlock on unshelve --- .../util/continuation/GeneralRunner.java | 6 +++--- .../util/continuation/SameProgressRunner.java | 16 +++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/util/continuation/GeneralRunner.java b/platform/vcs-impl/src/com/intellij/util/continuation/GeneralRunner.java index 04c3376e8df8..1ddfbb48bc48 100644 --- a/platform/vcs-impl/src/com/intellij/util/continuation/GeneralRunner.java +++ b/platform/vcs-impl/src/com/intellij/util/continuation/GeneralRunner.java @@ -245,11 +245,11 @@ abstract class GeneralRunner implements ContinuationContext { @Nullable protected TaskDescriptor getNextMatching() { while (true) { + if (myTriggerSuspend) { + return null; + } synchronized (myQueueLock) { if (myQueue.isEmpty()) return null; - if (myTriggerSuspend) { - return null; - } TaskDescriptor current = myQueue.remove(0); // check if some tasks were scheduled after disaster was thrown, anyway, they should also be checked for cure if (! current.isHaveMagicCure()) { diff --git a/platform/vcs-impl/src/com/intellij/util/continuation/SameProgressRunner.java b/platform/vcs-impl/src/com/intellij/util/continuation/SameProgressRunner.java index ae1172ce8e37..5ab3bab2364b 100644 --- a/platform/vcs-impl/src/com/intellij/util/continuation/SameProgressRunner.java +++ b/platform/vcs-impl/src/com/intellij/util/continuation/SameProgressRunner.java @@ -68,16 +68,14 @@ public class SameProgressRunner extends GeneralRunner { final TaskDescriptor current = getNextMatching(); if (current == null) { - synchronized (myQueueLock) { - if (myTriggerSuspend) { - mySemaphore.down(); - while (myTriggerSuspend) { - mySemaphore.waitFor(500); - } - continue; - } else { - return; + if (myTriggerSuspend) { + mySemaphore.down(); + while (myTriggerSuspend) { + mySemaphore.waitFor(500); } + continue; + } else { + return; } }