fix: replace GlobalScope with CoroutineScope+SupervisorJob to fix -Werror build
This commit is contained in:
@@ -106,6 +106,7 @@ class SshTerminalManager(
|
|||||||
|
|
||||||
private val jsch = JSch()
|
private val jsch = JSch()
|
||||||
private var session: Session? = null
|
private var session: Session? = null
|
||||||
|
private val ioScope = kotlinx.coroutines.CoroutineScope(Dispatchers.IO + kotlinx.coroutines.SupervisorJob())
|
||||||
private var channel: ChannelShell? = null
|
private var channel: ChannelShell? = null
|
||||||
private var sftpChannel: ChannelSftp? = null
|
private var sftpChannel: ChannelSftp? = null
|
||||||
private var inputStream: InputStream? = null
|
private var inputStream: InputStream? = null
|
||||||
@@ -165,7 +166,7 @@ class SshTerminalManager(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Start reading output in a separate coroutine (don't block connect())
|
// Start reading output in a separate coroutine (don't block connect())
|
||||||
readOutputJob = kotlinx.coroutines.GlobalScope.launch(Dispatchers.IO) {
|
readOutputJob = ioScope.launch(Dispatchers.IO) {
|
||||||
readOutput()
|
readOutput()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +241,7 @@ class SshTerminalManager(
|
|||||||
authMode = "key"
|
authMode = "key"
|
||||||
)
|
)
|
||||||
|
|
||||||
readOutputJob = kotlinx.coroutines.GlobalScope.launch(Dispatchers.IO) {
|
readOutputJob = ioScope.launch(Dispatchers.IO) {
|
||||||
readOutput()
|
readOutput()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,6 +417,7 @@ class SshTerminalManager(
|
|||||||
running.set(false)
|
running.set(false)
|
||||||
readOutputJob?.cancel()
|
readOutputJob?.cancel()
|
||||||
readOutputJob = null
|
readOutputJob = null
|
||||||
|
ioScope.cancel()
|
||||||
closeSftpChannel()
|
closeSftpChannel()
|
||||||
try { channel?.disconnect() } catch (_: Exception) {}
|
try { channel?.disconnect() } catch (_: Exception) {}
|
||||||
try { session?.disconnect() } catch (_: Exception) {}
|
try { session?.disconnect() } catch (_: Exception) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user