summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2019-09-30 11:30:16 +0200
committerLinus Färnstrand <linus@mullvad.net>2019-09-30 11:30:16 +0200
commitb49a7d7f0457bea5840d5fad0ed611c8d05d6576 (patch)
treec9f661cd4d4a5bf75816d93d520e0cab60e13a6a
parente9562c84a03598508d973099a4555eb9c8453913 (diff)
parentf2ba31d6f2e25b8201ad871178b26d412e324520 (diff)
downloadmullvadvpn-b49a7d7f0457bea5840d5fad0ed611c8d05d6576.tar.xz
mullvadvpn-b49a7d7f0457bea5840d5fad0ed611c8d05d6576.zip
Merge branch 'fix-relay-update-cmd'
-rw-r--r--CHANGELOG.md3
-rw-r--r--mullvad-daemon/src/relays.rs23
2 files changed, 14 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d1032a04cc..65f1b4c465 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,9 @@ Line wrap the file at 100 chars. Th
### Removed
- Remove support for `MULLVAD_LOCALE` environment variable.
+### Fixed
+- Fix `mullvad relay update` to trigger a relay list download even if the existing cache is new.
+
## [2019.8] - 2019-09-23
This release is identical to 2019.8-beta1
diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs
index eda9e083e2..34c699e832 100644
--- a/mullvad-daemon/src/relays.rs
+++ b/mullvad-daemon/src/relays.rs
@@ -729,8 +729,16 @@ impl RelayListUpdater {
fn run(&mut self) {
debug!("Starting relay list updater thread");
- while self.wait_for_next_iteration() {
- if self.should_update() {
+ loop {
+ let should_update = match self.close_handle.recv_timeout(UPDATE_CHECK_INTERVAL) {
+ // Someone sent an explicit update command
+ Ok(()) => true,
+ // Normal timeout, check cache age
+ Err(mpsc::RecvTimeoutError::Timeout) => self.should_update(),
+ // We have been canceled
+ Err(mpsc::RecvTimeoutError::Disconnected) => break,
+ };
+ if should_update {
match self.update() {
Ok(()) => info!("Updated list of relays"),
Err(error) => error!("{}", error.display_chain()),
@@ -740,16 +748,7 @@ impl RelayListUpdater {
debug!("Relay list updater thread has finished");
}
- fn wait_for_next_iteration(&mut self) -> bool {
- use self::mpsc::RecvTimeoutError::*;
-
- match self.close_handle.recv_timeout(UPDATE_CHECK_INTERVAL) {
- Ok(()) => true,
- Err(Timeout) => true,
- Err(Disconnected) => false,
- }
- }
-
+ /// Returns true if the current parsed_relays is older than UPDATE_INTERVAL
fn should_update(&mut self) -> bool {
match SystemTime::now().duration_since(self.parsed_relays.lock().last_updated()) {
Ok(duration) => duration > UPDATE_INTERVAL,