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