diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-06-15 15:45:34 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-06-15 15:46:34 +0200 |
| commit | e5ca34949b401bd5054ac7b9e3f69edcbecbd893 (patch) | |
| tree | 430cce553b8305d62349c16f8813d6a16d43a906 | |
| parent | 4232a432cba3642202b3756728ce07f20da077a2 (diff) | |
| download | mullvadvpn-e5ca34949b401bd5054ac7b9e3f69edcbecbd893.tar.xz mullvadvpn-e5ca34949b401bd5054ac7b9e3f69edcbecbd893.zip | |
Make tunnel close handle consume self
| -rw-r--r-- | talpid_core/src/tunnel/mod.rs | 2 | ||||
| -rw-r--r-- | talpid_core/src/tunnel/openvpn.rs | 9 |
2 files changed, 5 insertions, 6 deletions
diff --git a/talpid_core/src/tunnel/mod.rs b/talpid_core/src/tunnel/mod.rs index 3c955c563d..aead09b13b 100644 --- a/talpid_core/src/tunnel/mod.rs +++ b/talpid_core/src/tunnel/mod.rs @@ -90,7 +90,7 @@ pub struct CloseHandle(OpenVpnCloseHandle); impl CloseHandle { /// Closes the underlying tunnel, making the `TunnelMonitor::wait` method return. - pub fn close(&self) -> io::Result<()> { + pub fn close(self) -> io::Result<()> { self.0.close() } } diff --git a/talpid_core/src/tunnel/openvpn.rs b/talpid_core/src/tunnel/openvpn.rs index 651d7c3ca9..08c2c14a32 100644 --- a/talpid_core/src/tunnel/openvpn.rs +++ b/talpid_core/src/tunnel/openvpn.rs @@ -146,8 +146,7 @@ pub struct OpenVpnCloseHandle { impl OpenVpnCloseHandle { /// Kills the underlying OpenVPN process, making the `OpenVpnMonitor::wait` method return. - /// Only tries to close the OpenVPN process the first time it's called. - pub fn close(&self) -> io::Result<()> { + pub fn close(self) -> io::Result<()> { if !self.closed.swap(true, Ordering::SeqCst) { self.kill_openvpn() } else { @@ -156,12 +155,12 @@ impl OpenVpnCloseHandle { } #[cfg(unix)] - fn kill_openvpn(&self) -> io::Result<()> { - ::process::unix::nice_kill(self.child.clone(), *OPENVPN_DIE_TIMEOUT) + fn kill_openvpn(self) -> io::Result<()> { + ::process::unix::nice_kill(self.child, *OPENVPN_DIE_TIMEOUT) } #[cfg(not(unix))] - fn kill_openvpn(&self) -> io::Result<()> { + fn kill_openvpn(self) -> io::Result<()> { self.child.kill() } } |
