Do not handle the unix socket server in-place
Let the code after that actually run..
This commit is contained in:
parent
52ad012e13
commit
fa0bf056d0
1 changed files with 24 additions and 23 deletions
|
|
@ -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::<FuturesUnordered<_>>();
|
||||
debug!("starting..");
|
||||
tokio::select! {
|
||||
_ = server_tasks.join_all() => debug!("server tasks ended"),
|
||||
res = waiter.next() => debug!(?res, "child process terminated"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue