Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import scala.tools.nsc.interactive._ | ||
import tests._ | ||
|
||
/** Test that no ask calls are left unanswered after a compiler has shut down. */ | ||
object Test extends InteractiveTest { | ||
import compiler._ | ||
|
||
def askItem(): Response[Unit] = { | ||
compiler.askForResponse { () => | ||
Thread.sleep(100) | ||
} | ||
} | ||
|
||
final val Timeout = 5000 //ms | ||
|
||
override def main(args: Array[String]) { | ||
val item1 = askItem() | ||
|
||
compiler.askShutdown() | ||
|
||
Thread.sleep(1000) // wait a bit, the compiler is shutting down | ||
val item2 = askItem() | ||
|
||
item1.get(Timeout) match { | ||
case None => println("TIMEOUT") | ||
case _ => | ||
} | ||
item2.get(Timeout) match { | ||
case None => println("TIMEOUT") | ||
case _ => | ||
} | ||
} | ||
} |