Skip to content

Commit

Permalink
Fix tokio panic in legacy rpm-ostree container-encapsulate path
Browse files Browse the repository at this point in the history
Fixes: 60c8fac

We changed the method to be non-async (mostly) so it needs to run
from the worker thread.  There's a bit of the code which does
run async using `block_on` and we can only do that from the worker
thread.

Closes: #3968
  • Loading branch information
cgwalters committed Aug 25, 2022
1 parent aea8432 commit 07d0ebc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,13 @@ async fn inner_async_main(args: Vec<String>) -> Result<i32> {
);
return rpmostree_rust::container::entrypoint(&args_borrowed).await;
}
// This is a deprecated entrypoint
"container-encapsulate" => {
rpmostree_rust::client::warn_future_incompatibility(
"This entrypoint is deprecated; use `rpm-ostree compose container-encapsulate` instead",
);
rpmostree_rust::container::container_encapsulate(args)?;
return Ok(0);
}
_ => {}
}
// Everything below here is a blocking API, and run on a worker thread so
// that the main thread is dedicated to the Tokio reactor.
tokio::task::spawn_blocking(move || {
let args_borrowed: Vec<_> = args.iter().map(|s| s.as_str()).collect();
tokio::task::spawn_blocking(move || -> Result<i32, anyhow::Error> {
let args_orig = args;
let args_borrowed: Vec<_> = args_orig.iter().map(|s| s.as_str()).collect();
let args = &args_borrowed[..];
if let Some(arg) = args.get(1) {
match *arg {
Expand All @@ -54,6 +47,13 @@ async fn inner_async_main(args: Vec<String>) -> Result<i32> {
"usroverlay" | "unlock" => builtins::usroverlay::entrypoint(args).map(|_| 0),
// A hidden wrapper to intercept some binaries in RPM scriptlets.
"scriptlet-intercept" => builtins::scriptlet_intercept::entrypoint(args).map(|_| 0),
// This is a deprecated entrypoint
"container-encapsulate" => {
rpmostree_rust::client::warn_future_incompatibility(
"This entrypoint is deprecated; use `rpm-ostree compose container-encapsulate` instead",
);
rpmostree_rust::container::container_encapsulate(args_orig).map(|_| 0)
},
// C++ main
_ => Ok(rpmostree_rust::ffi::rpmostree_main(args)?),
}
Expand Down

0 comments on commit 07d0ebc

Please sign in to comment.