diff options
| author | Emīls Piņķis <emils@mullvad.net> | 2019-06-19 13:47:21 +0100 |
|---|---|---|
| committer | Emīls Piņķis <emils@mullvad.net> | 2019-06-26 14:18:38 +0100 |
| commit | aa738187dc7c8702be6754aaf86f304b716105f9 (patch) | |
| tree | 2a959f6c0c12aefad229df5505400b70f85875f0 | |
| parent | 17cb81960be1632993bdda4c50bb952cfe302424 (diff) | |
| download | mullvadvpn-aa738187dc7c8702be6754aaf86f304b716105f9.tar.xz mullvadvpn-aa738187dc7c8702be6754aaf86f304b716105f9.zip | |
Improve event loop usage in daemon
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 844c88d45e..43b071993c 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -1042,15 +1042,23 @@ where let private_key = wireguard::PrivateKey::new_from_random() .map_err(|e| format!("Failed to generate new key - {}", e))?; + let (tx, rx) = oneshot::channel(); let fut = self .wg_key_proxy - .push_wg_key(account_token, private_key.public_key()); + .push_wg_key(account_token, private_key.public_key()) + .then(move |result| { + let _ = tx.send(result); + Ok(()) + }); - let mut core = tokio_core::reactor::Core::new() - .map_err(|e| format!("Failed to spawn future for pushing wg key - {}", e))?; - let addresses = core - .run(fut) + self.tokio_remote + .execute(fut) + .map_err(|e| format!("Failed to spawn key pushing future - {:?}", e))?; + + let addresses = rx + .wait() + .map_err(|e| format!("Tokio reactor panicked: {}", e))? .map_err(|e| format!("Failed to push new wireguard key: {}", e))?; account_entry.wireguard = Some(mullvad_types::wireguard::WireguardData { |
