mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-01 14:22:34 -08:00
Catch exceptions from FramedWriter::write
Sentry-Issue-ID: 150818982
This commit is contained in:
2 files changed
+12
-5
No files matched your search
@@ -18,6 +18,7 @@ import dev.slimevr.solarxr.onSolarXRMessage
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.cancelChildren
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -31,6 +32,7 @@ import okio.Buffer
|
||||
import solarxr_protocol.MessageBundle
|
||||
import solarxr_protocol.rpc.EnableSteamVRDriverRequest
|
||||
import solarxr_protocol.rpc.OpenKeybindSettingsRequest
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class EnableSteamVRDriverBehaviour : SolarXRBridgeBehaviour {
|
||||
@@ -104,7 +106,12 @@ suspend fun handleSolarXRBridge(
|
||||
fbb.clear()
|
||||
fbb.finish(bundle.encode(JvmFlatBufferWriter(fbb)))
|
||||
sendBuffer.write(fbb.dataBuffer())
|
||||
send(sendBuffer)
|
||||
try {
|
||||
send(sendBuffer)
|
||||
} catch (e: IOException) {
|
||||
AppLogger.solarxr.warn("Exception when sending bundle to $name: ${e.message}")
|
||||
cancel()
|
||||
}
|
||||
}.launchIn(this)
|
||||
|
||||
bridge.startObserving()
|
||||
|
||||
@@ -57,8 +57,8 @@ private fun readFramedMessages(channel: SocketChannel) = flow {
|
||||
emit(frame)
|
||||
}
|
||||
} catch (e: SocketException) {
|
||||
AppLogger.ipc.warn("Exception on socket: ${e.message}")
|
||||
} catch (e: ClosedByInterruptException) {
|
||||
AppLogger.ipc.warn("Exception reading from socket: ${e.message}")
|
||||
} catch (_: ClosedByInterruptException) {
|
||||
AppLogger.ipc.info("Socket read interrupted, dropping connection")
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ private suspend fun acceptUnixClients(
|
||||
while (isActive) {
|
||||
val client = try {
|
||||
runInterruptible { server.accept() }
|
||||
} catch (e: ClosedByInterruptException) {
|
||||
} catch (_: ClosedByInterruptException) {
|
||||
break
|
||||
}
|
||||
AppLogger.ipc.info("$name client connected")
|
||||
@@ -135,7 +135,7 @@ private suspend fun acceptUnixClients(
|
||||
AppLogger.ipc.info("$name client disconnected")
|
||||
try {
|
||||
client.close()
|
||||
} catch (ignored: IOException) {
|
||||
} catch (_: IOException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user