Merge pull request #6164 from eatkins/thin-client-cancel

Make the thin client `cancel` command work reliably
This commit is contained in:
Ethan Atkins 2020-11-23 11:39:11 -08:00 committed by GitHub
commit 8e7e3efea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -162,7 +162,7 @@ private[sbt] final class CommandExchange {
e.source.map(_.channelName) == Some(c.name) && e.commandLine != Shutdown e.source.map(_.channelName) == Some(c.name) && e.commandLine != Shutdown
} }
currentExec.filter(_.source.map(_.channelName) == Some(c.name)).foreach { e => currentExec.filter(_.source.map(_.channelName) == Some(c.name)).foreach { e =>
Util.ignoreResult(NetworkChannel.cancel(e.execId, e.execId.getOrElse("0"))) Util.ignoreResult(NetworkChannel.cancel(e.execId, e.execId.getOrElse("0"), force = false))
} }
try commandQueue.put(Exec(s"${ContinuousCommands.stopWatch} ${c.name}", None)) try commandQueue.put(Exec(s"${ContinuousCommands.stopWatch} ${c.name}", None))
catch { case _: InterruptedException => } catch { case _: InterruptedException => }
@ -447,7 +447,7 @@ private[sbt] final class CommandExchange {
terminal.write(13, 13, 13, 4) terminal.write(13, 13, 13, 4)
terminal.printStream.println("\nconsole session killed by remote sbt client") terminal.printStream.println("\nconsole session killed by remote sbt client")
} else { } else {
Util.ignoreResult(NetworkChannel.cancel(e.execId, e.execId.getOrElse("0"))) Util.ignoreResult(NetworkChannel.cancel(e.execId, e.execId.getOrElse("0"), force = true))
} }
} }

View File

@ -923,7 +923,8 @@ object NetworkChannel {
case object InBody extends ChannelState case object InBody extends ChannelState
private[sbt] def cancel( private[sbt] def cancel(
execID: Option[String], execID: Option[String],
id: String id: String,
force: Boolean
): Either[String, String] = { ): Either[String, String] = {
Option(EvaluateTask.currentlyRunningTaskEngine.get) match { Option(EvaluateTask.currentlyRunningTaskEngine.get) match {
@ -945,7 +946,7 @@ object NetworkChannel {
// direct comparison on strings and // direct comparison on strings and
// remove hotspring unicode added character for numbers // remove hotspring unicode added character for numbers
if (checkId) { if (checkId || force) {
runningEngine.cancelAndShutdown() runningEngine.cancelAndShutdown()
Right(runningExecId) Right(runningExecId)
} else { } else {