Skip to content

Commit

Permalink
Allow vf manager to shutdown even if vmbus has an error.
Browse files Browse the repository at this point in the history
  • Loading branch information
erfrimod committed Jan 28, 2025
1 parent e2e84e3 commit e17e2a2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions openhcl/underhill_core/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,8 @@ impl UhVmNetworkSettings {
.await
},
));
let run_endpoints = async {
let run_endpoints = async move {
loop {
if endpoints.is_empty() {
continue;
}
let _ = endpoints
.iter_mut()
.map(|endpoint| endpoint.wait_for_endpoint_action())
Expand All @@ -735,10 +732,13 @@ impl UhVmNetworkSettings {
.await;
}
};
// Complete shutdown on the VFs. Process events on the endpoints to
// allow for proper shutdown.
// Note: race() means that when we exit only one of the two futures is completed and the other gets cancelled.
let _ = (shutdown_vfs, run_endpoints).race().await;

if error.is_some() {
shutdown_vfs.await;
} else {
// Wait for endpoints to close vmbus channels until VF shutdown completes
let _ = (shutdown_vfs, run_endpoints).race().await;
}

if let Some(e) = error {
return Err(e);
Expand Down

0 comments on commit e17e2a2

Please sign in to comment.