summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2021-02-23 18:18:11 +0100
committerDavid Lönnhager <david.l@mullvad.net>2021-02-26 10:36:57 +0100
commitc9374a3bda49f8ef4c43cade5c144b0df4e88e5d (patch)
tree39737bdf06ffe874d29c3c6139317a70f4459008
parentaf1a51e1e08d2a8074ae21f3f825b685642a241b (diff)
downloadmullvadvpn-c9374a3bda49f8ef4c43cade5c144b0df4e88e5d.tar.xz
mullvadvpn-c9374a3bda49f8ef4c43cade5c144b0df4e88e5d.zip
Make disconnecting state responsive when there is no close event
-rw-r--r--talpid-core/src/tunnel_state_machine/disconnecting_state.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
index 12e0bebe5e..7ddbdcf5da 100644
--- a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
@@ -196,16 +196,24 @@ impl TunnelState for DisconnectingState {
) -> EventConsequence {
use self::EventConsequence::*;
- if self.tunnel_close_event.is_terminated() {
- return NewState(self.after_disconnect(None, shared_values));
- }
-
- let result = runtime.block_on(async {
- futures::select! {
- command = commands.next() => EventResult::Command(command),
- result = &mut self.tunnel_close_event => EventResult::Close(result),
+ let result = if self.tunnel_close_event.is_terminated() {
+ if commands.is_done() {
+ EventResult::Close(Ok(None))
+ } else {
+ if let Ok(command) = commands.get_mut().try_next() {
+ EventResult::Command(command)
+ } else {
+ EventResult::Close(Ok(None))
+ }
}
- });
+ } else {
+ runtime.block_on(async {
+ futures::select! {
+ command = commands.next() => EventResult::Command(command),
+ result = &mut self.tunnel_close_event => EventResult::Close(result),
+ }
+ })
+ };
match result {
EventResult::Command(command) => self.handle_commands(command, shared_values),