Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on tokio_unstable config flag #62

Open
wants to merge 1 commit into
base: movement
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ xclippy = [
x = "run --package aptos-cargo-cli --bin aptos-cargo-cli --"

[build]
rustflags = ["--cfg", "tokio_unstable", "-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes"]
rustflags = ["-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes"]

# TODO(grao): Figure out whether we should enable othaer cpu features, and whether we should use a different way to configure them rather than list every single one here.
[target.x86_64-unknown-linux-gnu]
rustflags = ["--cfg", "tokio_unstable", "-C", "link-arg=-fuse-ld=lld", "-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes", "-C", "target-feature=+sse4.2"]
rustflags = ["-C", "link-arg=-fuse-ld=lld", "-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes", "-C", "target-feature=+sse4.2"]

# 64 bit MSVC
[target.x86_64-pc-windows-msvc]
rustflags = [
"--cfg",
"tokio_unstable",
"-C",
"force-frame-pointers=yes",
"-C",
Expand Down
1 change: 0 additions & 1 deletion crates/aptos-runtimes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ where
format!("{}-{}", thread_name_clone, id)
})
.on_thread_start(on_thread_start)
.disable_lifo_slot()
// Limit concurrent blocking tasks from spawn_blocking(), in case, for example, too many
// Rest API calls overwhelm the node.
.max_blocking_threads(MAX_BLOCKING_THREADS)
Expand Down
20 changes: 9 additions & 11 deletions crates/aptos/src/node/local_testnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,14 @@ impl CliCommand<()> for RunLocalnet {
.collect();

let mut join_set = JoinSet::new();
let mut task_id = 0usize;

// Start each of the services.
for manager in managers.into_iter() {
join_set.spawn(manager.run());
task_id += 1;
join_set.spawn(async move {
manager.run().await.map(|()| task_id)
});
}

// Wait for all the services to start up. While doing so we also wait for any
Expand Down Expand Up @@ -398,29 +402,23 @@ impl CliCommand<()> for RunLocalnet {
// see `ShutdownStep` for more info. In particular, to speak to how "best effort"
// this really is, to make sure ctrl-c happens more or less instantly, we only
// register this handler after all the services have started.
let abort_handle = join_set.spawn(async move {
join_set.spawn(async move {
tokio::signal::ctrl_c()
.await
.expect("Failed to register ctrl-c hook");
Ok(())
Ok(0)
});
let ctrl_c_task_id = abort_handle.id();

// Wait for one of the tasks to end. We should never get past this point unless
// something goes goes wrong or the user signals for the process to end. We
// unwrap once because we know for certain the set is not empty and that's the
// only condition in which this can return `None`.
let result = join_set.join_next_with_id().await.unwrap();
let result = join_set.join_next().await.unwrap();

// We want to print a different message depending on which task ended. We can
// determine if the task that ended was the ctrl-c task based on the ID of the
// task.
let finished_task_id = match &result {
Ok((id, _)) => *id,
Err(err) => err.id(),
};

let was_ctrl_c = finished_task_id == ctrl_c_task_id;
let was_ctrl_c = matches!(result, Ok(Ok(id)) if id == 0);
if was_ctrl_c {
eprintln!("\nReceived ctrl-c, running shutdown steps...");
} else {
Expand Down