diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-04-14 21:41:26 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-04-15 12:00:12 +0000 |
| commit | b7a41929abe64c7b626796491209820121bd670b (patch) | |
| tree | cc0b0130c775c5212838ada76a134d75b131ca70 /android/src | |
| parent | a708c01f13b9b45fd56a2504b4568868b0196ebb (diff) | |
| download | mullvadvpn-b7a41929abe64c7b626796491209820121bd670b.tar.xz mullvadvpn-b7a41929abe64c7b626796491209820121bd670b.zip | |
Fix `AccountCache` only handled first request
The app would previously crash when the UI side `AccountCache` class
sent a second request message to the service side `AccountCache` class.
The simplest way to reproduce this was to log out and log in again. This
was happening because the service side `AccountCache` actor
implementation was only handling one request and then stopping.
This is now fixed by having the actor run a loop to handle all incoming
requests.
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt index 74cdc3f11f..50f0f5940c 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt @@ -163,12 +163,12 @@ class AccountCache(private val endpoint: ServiceEndpoint) { private fun spawnActor() = GlobalScope.actor<Command>(Dispatchers.Default, Channel.UNLIMITED) { try { - val command = channel.receive() - - when (command) { - is Command.CreateAccount -> doCreateAccount() - is Command.Login -> doLogin(command.account) - is Command.Logout -> doLogout() + for (command in channel) { + when (command) { + is Command.CreateAccount -> doCreateAccount() + is Command.Login -> doLogin(command.account) + is Command.Logout -> doLogout() + } } } catch (exception: ClosedReceiveChannelException) { // Command channel was closed, stop the actor |
