Proper synchronization
This commit is contained in:
parent
e613855a4f
commit
60f3d62f00
@ -43,8 +43,6 @@ import java.security.SecureRandom
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
private var haveActiveSession: Boolean = false
|
|
||||||
|
|
||||||
abstract class MagiskInstallImpl protected constructor(
|
abstract class MagiskInstallImpl protected constructor(
|
||||||
protected val console: MutableList<String> = NOPList.getInstance(),
|
protected val console: MutableList<String> = NOPList.getInstance(),
|
||||||
private val logs: 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
|
protected abstract suspend fun operations(): Boolean
|
||||||
|
|
||||||
open suspend fun exec(): Boolean {
|
open suspend fun exec(): Boolean {
|
||||||
synchronized(haveActiveSession) {
|
synchronized(Companion) {
|
||||||
if (haveActiveSession)
|
if (haveActiveSession)
|
||||||
return false
|
return false
|
||||||
haveActiveSession = true
|
haveActiveSession = true
|
||||||
}
|
}
|
||||||
val result = withContext(Dispatchers.IO) { operations() }
|
val result = withContext(Dispatchers.IO) { operations() }
|
||||||
synchronized(haveActiveSession) {
|
synchronized(Companion) {
|
||||||
haveActiveSession = false
|
haveActiveSession = false
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var haveActiveSession = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class MagiskInstaller(
|
abstract class MagiskInstaller(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user