diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-05-10 15:46:23 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-05-11 17:42:53 +0200 |
| commit | 0135cf3e582240aa5b5fffcfbec3fb2d9277ed93 (patch) | |
| tree | e2aecb9e2f5f2df2fd0cf30ffb87bee95c45d0da | |
| parent | 03406b1c6ed16f75d98b7fd9a3a09dcb9c0836d3 (diff) | |
| download | mullvadvpn-0135cf3e582240aa5b5fffcfbec3fb2d9277ed93.tar.xz mullvadvpn-0135cf3e582240aa5b5fffcfbec3fb2d9277ed93.zip | |
Don't stop device check if an API request is aborted
| -rw-r--r-- | mullvad-api/src/rest.rs | 7 | ||||
| -rw-r--r-- | mullvad-daemon/src/device/mod.rs | 20 |
2 files changed, 25 insertions, 2 deletions
diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index d174c3d19c..84560e07ba 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -84,6 +84,13 @@ impl Error { } } + pub fn is_aborted(&self) -> bool { + match self { + Error::Aborted => true, + _ => false, + } + } + /// Returns a new instance for which `abortable_stream::Aborted` is mapped to `Self::Aborted`. fn map_aborted(self) -> Self { if let Error::HyperError(error) = &self { diff --git a/mullvad-daemon/src/device/mod.rs b/mullvad-daemon/src/device/mod.rs index 3ab8c97dee..5b2c21ae71 100644 --- a/mullvad-daemon/src/device/mod.rs +++ b/mullvad-daemon/src/device/mod.rs @@ -182,12 +182,28 @@ impl PrivateDeviceEvent { impl Error { pub fn is_network_error(&self) -> bool { - if let Error::OtherRestError(error) = self { + if let Error::OtherRestError(error) = self.unpack() { error.is_network_error() } else { false } } + + pub fn is_aborted(&self) -> bool { + if let Error::OtherRestError(error) = self.unpack() { + error.is_aborted() + } else { + false + } + } + + fn unpack(&self) -> &Error { + if let Error::ResponseFailure(ref inner) = self { + &*inner + } else { + self + } + } } type ResponseTx<T> = oneshot::Sender<Result<T, Error>>; @@ -891,7 +907,7 @@ impl TunnelStateChangeHandler { "{}", error.display_chain_with_msg("Failed to check device validity") ); - if error.is_network_error() { + if error.is_network_error() || error.is_aborted() { check_validity.store(true, Ordering::SeqCst); } } |
