Wrap race condition in CancellationException
This commit is contained in:
@@ -231,8 +231,12 @@ class RootServer {
|
|||||||
* Caller should check for active.
|
* Caller should check for active.
|
||||||
*/
|
*/
|
||||||
private fun sendLocked(command: Parcelable) {
|
private fun sendLocked(command: Parcelable) {
|
||||||
output.writeParcelable(command)
|
try {
|
||||||
output.flush()
|
output.writeParcelable(command)
|
||||||
|
output.flush()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
if (e.isEBADF) throw CancellationException().initCause(e) else throw e
|
||||||
|
}
|
||||||
Logger.me.d("Sent #$counter: $command")
|
Logger.me.d("Sent #$counter: $command")
|
||||||
counter++
|
counter++
|
||||||
}
|
}
|
||||||
@@ -300,8 +304,9 @@ class RootServer {
|
|||||||
sendLocked(Shutdown())
|
sendLocked(Shutdown())
|
||||||
output.close()
|
output.close()
|
||||||
process.outputStream.close()
|
process.outputStream.close()
|
||||||
|
} catch (_: CancellationException) {
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
if (!e.isEBADF) Logger.me.w("send Shutdown failed", e)
|
Logger.me.w("send Shutdown failed", e)
|
||||||
}
|
}
|
||||||
Logger.me.d("Client closed")
|
Logger.me.d("Client closed")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user