Do not handle the unix socket server in-place

Let the code after that actually run..
This commit is contained in:
Val Packett 2025-11-14 06:09:05 -03:00
parent 52ad012e13
commit fa0bf056d0

View file

@ -165,29 +165,31 @@ async fn main() -> eyre::Result<()> {
if let Some(path) = cli.unix_path { if let Some(path) = cli.unix_path {
// XXX: going through the channel just to strip fds // XXX: going through the channel just to strip fds
let vm_unix_listener = UnixListener::bind(path)?; let vm_unix_listener = UnixListener::bind(path)?;
while let Ok((socket, remote_addr)) = vm_unix_listener.accept().await { server_tasks.spawn(enclose! { (vm_bus, vm_bus_guid) async move {
let f = enclose! { (vm_bus, vm_bus_guid) async move { while let Ok((socket, remote_addr)) = vm_unix_listener.accept().await {
let client_conn = zbus::connection::Builder::unix_stream(socket) let f = enclose! { (vm_bus, vm_bus_guid) async move {
.server(&vm_bus_guid) let client_conn = zbus::connection::Builder::unix_stream(socket)
.unwrap() .server(&vm_bus_guid)
.p2p() .unwrap()
.auth_mechanism(zbus::AuthMechanism::Anonymous) .p2p()
.build() .auth_mechanism(zbus::AuthMechanism::Anonymous)
.await?; .build()
let vmbus_conn = vm_bus.lock().await.connect_channel(true).await?; .await?;
sidebus_common::raw::splice_conns(client_conn, vmbus_conn).await; let vmbus_conn = vm_bus.lock().await.connect_channel(true).await?;
Ok::<(), eyre::Report>(()) sidebus_common::raw::splice_conns(client_conn, vmbus_conn).await;
} }; Ok::<(), eyre::Report>(())
tokio::spawn( } };
async { tokio::spawn(
match f.await { async {
Ok(()) => debug!("done with client"), match f.await {
Err(err) => error!(%err, "error dealing with client"), Ok(()) => debug!("done with client"),
Err(err) => error!(%err, "error dealing with client"),
}
} }
} .instrument(info_span!("serve", ?remote_addr)),
.instrument(info_span!("serve", ?remote_addr)), );
); }
} } });
} }
if let Some(port) = cli.vsock_port { if let Some(port) = cli.vsock_port {
@ -217,7 +219,6 @@ async fn main() -> eyre::Result<()> {
.iter_mut() .iter_mut()
.map(|child| child.wait()) .map(|child| child.wait())
.collect::<FuturesUnordered<_>>(); .collect::<FuturesUnordered<_>>();
debug!("starting..");
tokio::select! { tokio::select! {
_ = server_tasks.join_all() => debug!("server tasks ended"), _ = server_tasks.join_all() => debug!("server tasks ended"),
res = waiter.next() => debug!(?res, "child process terminated"), res = waiter.next() => debug!(?res, "child process terminated"),