Skip to content

Commit

Permalink
🔥 zb: Remove some unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
zeenix committed May 1, 2024
1 parent 4d53e77 commit e772909
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions zbus/src/connection/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,25 @@ impl ReadHalf for Arc<Async<TcpStream>> {
}
}

#[cfg(windows)]
async fn peer_credentials(&mut self) -> io::Result<crate::fdo::ConnectionCredentials> {
#[cfg(windows)]
let creds = {
let stream = self.clone();
crate::Task::spawn_blocking(
move || {
use crate::win32::{tcp_stream_get_peer_pid, ProcessToken};

let pid = tcp_stream_get_peer_pid(stream.get_ref())? as _;
let sid = ProcessToken::open(if pid != 0 { Some(pid as _) } else { None })
.and_then(|process_token| process_token.sid())?;
io::Result::Ok(
crate::fdo::ConnectionCredentials::default()
.set_process_id(pid)
.set_windows_sid(sid),
)
},
"peer credentials",
)
.await
}?;

#[cfg(not(windows))]
let creds = crate::fdo::ConnectionCredentials::default();

Ok(creds)
let stream = self.clone();
crate::Task::spawn_blocking(
move || {
use crate::win32::{tcp_stream_get_peer_pid, ProcessToken};

let pid = tcp_stream_get_peer_pid(stream.get_ref())? as _;
let sid = ProcessToken::open(if pid != 0 { Some(pid as _) } else { None })
.and_then(|process_token| process_token.sid())?;
io::Result::Ok(
crate::fdo::ConnectionCredentials::default()
.set_process_id(pid)
.set_windows_sid(sid),
)
},
"peer credentials",
)
.await
}
}

Expand Down

0 comments on commit e772909

Please sign in to comment.