Commit 60f3d62f authored by topjohnwu's avatar topjohnwu

Proper synchronization

parent e613855a
......@@ -43,8 +43,6 @@ import java.security.SecureRandom
import java.util.*
import java.util.zip.ZipFile
private var haveActiveSession: Boolean = false
abstract class MagiskInstallImpl protected constructor(
protected val console: MutableList<String> = NOPList.getInstance(),
private val logs: MutableList<String> = NOPList.getInstance()
......@@ -418,17 +416,21 @@ abstract class MagiskInstallImpl protected constructor(
protected abstract suspend fun operations(): Boolean
open suspend fun exec(): Boolean {
synchronized(haveActiveSession) {
synchronized(Companion) {
if (haveActiveSession)
return false
haveActiveSession = true
}
val result = withContext(Dispatchers.IO) { operations() }
synchronized(haveActiveSession) {
synchronized(Companion) {
haveActiveSession = false
}
return result
}
companion object {
private var haveActiveSession = false
}
}
abstract class MagiskInstaller(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment