diff options
| author | Linus Färnstrand <faern@faern.net> | 2022-03-23 14:30:52 +0100 |
|---|---|---|
| committer | Linus Färnstrand <faern@faern.net> | 2022-03-24 11:02:55 +0100 |
| commit | e571fe7f812ee3d0e613052f33f1f5d3bf63d240 (patch) | |
| tree | 0103647fa15402dd5c9db37cd168176ca69cc376 | |
| parent | 8ae9b95daa4db47fdf630559b1b698fd635e5c49 (diff) | |
| download | mullvadvpn-e571fe7f812ee3d0e613052f33f1f5d3bf63d240.tar.xz mullvadvpn-e571fe7f812ee3d0e613052f33f1f5d3bf63d240.zip | |
Remove add_list and just add PIDs one at a time
There was a bug where adding multiple PIDs simply never
worked. They were not being separated by any separator in
the file that was written to
| -rw-r--r-- | talpid-core/src/proxy/shadowsocks.rs | 19 | ||||
| -rw-r--r-- | talpid-core/src/split_tunnel/linux.rs | 14 |
2 files changed, 11 insertions, 22 deletions
diff --git a/talpid-core/src/proxy/shadowsocks.rs b/talpid-core/src/proxy/shadowsocks.rs index 7fbf4cb5f9..6436e967c5 100644 --- a/talpid-core/src/proxy/shadowsocks.rs +++ b/talpid-core/src/proxy/shadowsocks.rs @@ -186,17 +186,14 @@ impl ShadowsocksProxyMonitor { error.display_chain_with_msg("Failed to initialize PidManager"), ) })?; - let i32_pids = subproc - .pids() - .iter() - .map(|pid| *pid as i32) - .collect::<Vec<_>>(); - excluded_pids.add_list(&i32_pids).map_err(|error| { - Error::new( - ErrorKind::Other, - error.display_chain_with_msg("Failed to exclude Shadowsocks process"), - ) - })?; + for pid in subproc.pids() { + excluded_pids.add(pid as i32).map_err(|error| { + Error::new( + ErrorKind::Other, + error.display_chain_with_msg("Failed to exclude Shadowsocks process"), + ) + })?; + } } match Self::get_bound_port(File::open(&logfile)?, &subproc) { diff --git a/talpid-core/src/split_tunnel/linux.rs b/talpid-core/src/split_tunnel/linux.rs index 6944aada4d..83296439f5 100644 --- a/talpid-core/src/split_tunnel/linux.rs +++ b/talpid-core/src/split_tunnel/linux.rs @@ -103,11 +103,6 @@ impl PidManager { /// Add a PID to exclude from the tunnel. pub fn add(&self, pid: i32) -> Result<(), Error> { - self.add_list(&[pid]) - } - - /// Add PIDs to exclude from the tunnel. - pub fn add_list<T: Into<i32> + ToString>(&self, pids: &[T]) -> Result<(), Error> { let exclusions_path = self .net_cls_path .join(SPLIT_TUNNEL_CGROUP_NAME) @@ -121,12 +116,9 @@ impl PidManager { let mut writer = BufWriter::new(file); - for pid in pids { - writer - .write_all(pid.to_string().as_bytes()) - .map_err(Error::AddCGroupPid)?; - } - + writer + .write_all(pid.to_string().as_bytes()) + .map_err(Error::AddCGroupPid)?; Ok(()) } |
