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

Gracefully shutdown if SIGINT was sent in TUI mode #2784

Merged
merged 4 commits into from
May 3, 2019

Conversation

hashmap
Copy link
Contributor

@hashmap hashmap commented Apr 29, 2019

Fixes #2799

Also 2 Arc's were replaced by one server's instance.
It is needed for p2p thread management in #2778, currently there is no point where we could store thread handles and join them because thread::join
consume the caller, which is impossible in case of Arc.

hashmap added 2 commits April 29, 2019 22:38
It is needed for p2p thread management, currently there is no point
where we could store thread handles and join themm because thread::join
consume the caller, which is impossible in case of Arc.
Also we don't need to check running flag constantly and it's easier to
reason about the state.
@hashmap hashmap changed the title Do not wrap Server into Arc [WIP] Do not wrap Server into Arc Apr 30, 2019
@hashmap hashmap added the task label Apr 30, 2019
@hashmap hashmap changed the title [WIP] Do not wrap Server into Arc Handle SIGINT in TUI mode May 2, 2019
@hashmap hashmap changed the title Handle SIGINT in TUI mode Gracefully shutdown if SIGINT was sent in TUI mode May 2, 2019
@hashmap hashmap requested a review from antiochp May 3, 2019 11:27
@@ -101,13 +101,8 @@ impl Server {
}
}

info_callback(serv.clone());
loop {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

let running = Arc::new(AtomicBool::new(true));
let _ = thread::Builder::new()
.name("ui".to_string())
.spawn(move || {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we now run the TUI in the main thread and not in a separate ui thread?
Is there any downside to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's symmetrical with non-tui case. Also to be fair I'm not sure, it seems that cursive creates a separate thread anyway, but I'm not an expert. What I see is that SIGINT is magically handled (in ncurses backend or most likely in C code, because I didn't find any traces of it in cursive) and it stops only UI, so we are able to call server.stop() in the main thread after that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@antiochp antiochp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hashmap hashmap merged commit 55cbdf5 into mimblewimble:master May 3, 2019
@hashmap hashmap deleted the one-server branch May 3, 2019 12:20
@antiochp antiochp added this to the 1.1.0 milestone Jun 5, 2019
@antiochp antiochp added the release notes To be included in release notes (of relevant milestone). label Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes To be included in release notes (of relevant milestone). task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If TUI is enabled Ctrl-C doesn't start graceful shutdown
2 participants