Handle unexpected death
This commit is contained in:
@@ -88,6 +88,8 @@ class RootServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UnexpectedExitException : RemoteException("Root process exited unexpectedly")
|
||||||
|
|
||||||
private lateinit var process: Process
|
private lateinit var process: Process
|
||||||
/**
|
/**
|
||||||
* Thread safety: needs to be protected by mutex.
|
* Thread safety: needs to be protected by mutex.
|
||||||
@@ -206,7 +208,7 @@ class RootServer {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
callbackSpin()
|
callbackSpin()
|
||||||
if (active) throw RemoteException("Root process exited unexpectedly")
|
if (active) throw UnexpectedExitException()
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
process.destroy()
|
process.destroy()
|
||||||
throw e
|
throw e
|
||||||
@@ -317,6 +319,8 @@ class RootServer {
|
|||||||
} catch (e: TimeoutCancellationException) {
|
} catch (e: TimeoutCancellationException) {
|
||||||
Logger.me.w("Closing the instance has timed out", e)
|
Logger.me.w("Closing the instance has timed out", e)
|
||||||
if (Build.VERSION.SDK_INT < 26) process.destroy() else if (process.isAlive) process.destroyForcibly()
|
if (Build.VERSION.SDK_INT < 26) process.destroy() else if (process.isAlive) process.destroyForcibly()
|
||||||
|
} catch (e: UnexpectedExitException) {
|
||||||
|
Logger.me.w(e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,11 +58,7 @@ abstract class RootSession {
|
|||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
check(usersCount == 0L)
|
check(usersCount == 0L)
|
||||||
timeoutJob = null
|
timeoutJob = null
|
||||||
try {
|
|
||||||
closeLocked()
|
closeLocked()
|
||||||
} catch (e: Exception) {
|
|
||||||
Logger.me.e("Closing RootServer on timeout failed", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user