This commit is contained in:
2026-04-30 21:41:50 +01:00
parent f0f7f5d9fa
commit 4c22cfbe0f
+1 -15
View File
@@ -20,7 +20,6 @@ use std::os::unix::net::{
};
use libc::{
WEXITSTATUS,
pollfd,
poll,
POLLIN,
@@ -55,13 +54,12 @@ fn fork_lua(lua : &Lua, args: Vec<String>, fds: Vec<i32>) -> Option<i32> {
};
let chunk = lua.load(path);
match chunk.exec() {
Ok(()) => { println!("lua returned ok"); },
Ok(()) => { exit(0); },
Err(e) => {
println!("lua error {:?}", e);
exit(1);
},
};
exit(0);
},
Err(e) => {
println!("fork error {:?}", e);
@@ -80,7 +78,6 @@ fn read_ancillary_data(ancillary : SocketAncillary<'_>) -> Vec<i32> {
}
}
}
println!("fds {:?}", fds);
fds
}
@@ -113,13 +110,6 @@ fn main() -> std::io::Result<()> {
let sock = UnixDatagram::bind(sock_path)?;
let mut peers : HashMap<i32, SocketAddr> = HashMap::new();
// listen for datagrams. each time we get one, fork a child
// to run lua script with the datagram payload and its stdio
// connected to the passed fds. when the lua subprocess exits,
// write the exit status back to the peer
// this implies we need a map of child pid -> peer address
loop {
let mut buf = [0u8; 1024];
@@ -143,10 +133,6 @@ fn main() -> std::io::Result<()> {
];
let n_ready = unsafe { poll(pollfds.as_mut_ptr(), 2, 10000) };
if n_ready > 0 {
println!("data! {n_ready}, {:?}, {:?}",
pollfds[0].revents,
pollfds[1].revents
);
if pollfds[0].revents > 0 {
match sock.recv_vectored_with_ancillary_from(&mut bufs, &mut ancillary) {
Ok((size, _truncated, peer)) => {