diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-03-07 19:07:31 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-03-09 10:44:48 -0300 |
| commit | 4d70d7aadb4581ce893c61b84c663105d33d4cdd (patch) | |
| tree | 0af8c25f5e894837347ff726a1c5cad7b45ca2cd | |
| parent | 72049bc9a3f876a78c18e75a783216ca48db5e3b (diff) | |
| download | mullvadvpn-4d70d7aadb4581ce893c61b84c663105d33d4cdd.tar.xz mullvadvpn-4d70d7aadb4581ce893c61b84c663105d33d4cdd.zip | |
Separate address retrieval from RPC call
Refactor so that if the former fails (which is a normal and frequent
situation) nothing is logged.
| -rw-r--r-- | mullvad-daemon/src/rpc_uniqueness_check.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/mullvad-daemon/src/rpc_uniqueness_check.rs b/mullvad-daemon/src/rpc_uniqueness_check.rs index f06daa8ba3..e2479a27d3 100644 --- a/mullvad-daemon/src/rpc_uniqueness_check.rs +++ b/mullvad-daemon/src/rpc_uniqueness_check.rs @@ -11,19 +11,22 @@ use rpc_address_file; /// Tries to connect to another daemon and perform a simple RPC call. If it fails, assumes the /// other daemon has stopped. pub fn is_another_instance_running() -> bool { - if let Err(message) = call_other_daemon() { - info!("{}; assuming it has stopped", message); - false + if let Ok(address) = rpc_address_file::read() { + match call_other_instance(address) { + Ok(_) => true, + Err(message) => { + info!("{}; assuming it has stopped", message); + false + } + } } else { - true + false } } -fn call_other_daemon() -> result::Result<(), String> { +fn call_other_instance(address: String) -> result::Result<(), String> { let method = "get_state"; let args: [u8; 0] = []; - let address = - rpc_address_file::read().map_err(|_| "Failed to read RPC address file of other daemon")?; // TODO: Authenticate with server let mut rpc_client = WsIpcClient::new(address).map_err(|_| "Failed to connect to other daemon")?; |
