Skip to content
Browse files

Fixed SI-6505. Respond to ask calls by immediate failure even after c…

…ompiler shutdown.

When the compiler is asked to shutdown, it may still have items on the working queue, and more can be added by clients in other thread that don't *know* the compiler is down yet. These requests were never serviced, leading to deadlocks or timeouts.

review by @odersky, @hubertp(cherry picked from commit 19ea47b)

Conflicts:
	src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
  • Loading branch information...
1 parent 67e4681 commit e90fd5d4574945778bae11703644f25f011e11ff @dragos dragos committed Oct 10, 2012
View
11 src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -12,6 +12,7 @@ import scala.tools.nsc.symtab._
import scala.tools.nsc.ast._
import scala.tools.nsc.util.FailedInterrupt
import scala.tools.nsc.util.EmptyAction
+import scala.tools.nsc.util.InterruptReq
/** Interface of interactive compiler to a client such as an IDE
* The model the presentation compiler consists of the following parts:
@@ -412,6 +413,16 @@ trait CompilerControl { self: Global =>
override def doQuickly[A](op: () => A): A = {
throw new FailedInterrupt(new Exception("Posted a work item to a compiler that's shutting down"))
}
+
+ override def askDoQuickly[A](op: () => A): InterruptReq { type R = A } = {
+ val ir = new InterruptReq {
+ type R = A
+ val todo = () => throw new MissingResponse
+ }
+ ir.execute()
+ ir
+ }
+
}
}
View
5 src/compiler/scala/tools/nsc/util/InterruptReq.scala
@@ -48,7 +48,10 @@ abstract class InterruptReq {
}
def onComplete(k: Continuation) = synchronized {
- waiting = k :: waiting
+ if (result.isDefined)
+ k(result.get)
+ else
+ waiting = k :: waiting
}
}

0 comments on commit e90fd5d

Please sign in to comment.
Something went wrong with that request. Please try again.