Fix canonical input for network client

It is valid for the thin client input stream to return -1 as an EOF when
the user inputs ctrl+d in canonical mode.
This commit is contained in:
Ethan Atkins
2020-10-21 14:26:21 -07:00
parent 50f649c3c9
commit a0db985c36
2 changed files with 7 additions and 14 deletions
@@ -934,12 +934,9 @@ class NetworkClient(
val stopped = new AtomicBoolean(false)
override final def run(): Unit = {
def read(): Unit = {
inputStream.read match {
case -1 =>
case b =>
inLock.synchronized(stdinBytes.offer(b))
if (attached.get()) drain()
}
val b = inputStream.read
inLock.synchronized(stdinBytes.offer(b))
if (attached.get()) drain()
}
try read()
catch { case _: InterruptedException | NonFatal(_) => stopped.set(true) } finally {