Merge pull request #6073 from eatkins/fix-console-cancellation

Fix console task cancellation
This commit is contained in:
eugene yokota 2020-11-06 17:37:06 -05:00 committed by GitHub
commit ac6c962a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -457,7 +457,7 @@ object Terminal {
extends SimpleInputStream
with AutoCloseable {
private[this] val isRaw = new AtomicBoolean(false)
final def write(bytes: Int*): Unit = readThread.synchronized {
final def write(bytes: Int*): Unit = buffer.synchronized {
bytes.foreach(b => buffer.put(b))
}
def setRawMode(toggle: Boolean): Unit = {
@ -488,7 +488,7 @@ object Terminal {
@tailrec def impl(): Unit = {
val _ = readQueue.take
val b = in.read
buffer.put(b)
buffer.synchronized(buffer.put(b))
if (Thread.interrupted() || (b == -1 && isRaw.get)) closed.set(true)
else impl()
}