aboutsummaryrefslogtreecommitdiffstats
path: root/src/export_fun.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/export_fun.rs')
-rw-r--r--src/export_fun.rs32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/export_fun.rs b/src/export_fun.rs
index ff1feeb..26ab88c 100644
--- a/src/export_fun.rs
+++ b/src/export_fun.rs
@@ -49,14 +49,9 @@ fn handle_server(session: Arc<Mutex<Session>>, mut stream: UnixStream) -> io::Re
let bytelen = stream.recv_vectored_with_ancillary(&mut iov, &mut ancillary)?;
for msg in ancillary.messages() {
- if let Ok(msg) = msg {
- match msg {
- AncillaryData::ScmRights(rights) => {
- for fd in rights {
- fds.push(fd);
- }
- }
- _ => (),
+ if let Ok(AncillaryData::ScmRights(rights)) = msg {
+ for fd in rights {
+ fds.push(fd);
}
}
}
@@ -155,13 +150,14 @@ pub fn prepare_command(session: Arc<Mutex<Session>>, cmd: &mut Command) {
pub fn maybe_run_defined_function() {
if let Some(program_name) = std::env::args_os().next() {
let program_name = program_name.as_bytes();
- if !program_name.contains(&b'/') && program_name != b"pish" {
- if let Some(socket) = std::env::var_os("PISH_SOCKET") {
- if let Ok(stream) = UnixStream::connect(socket) {
- let _ = handle_client(stream);
- }
- exit(-1);
+ if !program_name.contains(&b'/')
+ && program_name != b"pish"
+ && let Some(socket) = std::env::var_os("PISH_SOCKET")
+ {
+ if let Ok(stream) = UnixStream::connect(socket) {
+ let _ = handle_client(stream);
}
+ exit(-1);
}
}
}
@@ -267,11 +263,9 @@ pub fn listen(session: Arc<Mutex<Session>>) -> impl Drop {
_ => (),
}
- if is_ready {
- if let Ok((stream, _addr)) = listener.accept() {
- let se = se.clone();
- thread::spawn(move || handle_server(se, stream));
- }
+ if is_ready && let Ok((stream, _addr)) = listener.accept() {
+ let se = se.clone();
+ thread::spawn(move || handle_server(se, stream));
}
}
});