summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-api/src/rest.rs7
-rw-r--r--mullvad-daemon/src/device/mod.rs20
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);
}
}