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

fix: fix console wallet tick events endless loop edge case at shutdown #3380

Merged
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
12 changes: 8 additions & 4 deletions applications/tari_console_wallet/src/utils/crossterm_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ impl CrosstermEvents {
) {
Ok(true) => {
if let Ok(CEvent::Key(key)) = event::read() {
if let Err(e) = tx.send(Event::Input(key)) {
warn!(target: LOG_TARGET, "Error sending Tick event on MPSC channel: {}", e);
if tx.send(Event::Input(key)).is_err() {
info!(target: LOG_TARGET, "Tick event channel shutting down");
// A send operation can only fail if the receiving end of a channel is disconnected.
break;
}
}
},
Expand All @@ -81,8 +83,10 @@ impl CrosstermEvents {
},
}
if last_tick.elapsed() >= config.tick_rate {
if let Err(e) = tx.send(Event::Tick) {
warn!(target: LOG_TARGET, "Error sending Tick event on MPSC channel: {}", e);
if tx.send(Event::Tick).is_err() {
info!(target: LOG_TARGET, "Tick event channel shutting down");
// A send operation can only fail if the receiving end of a channel is disconnected.
break;
}
last_tick = Instant::now();
}
Expand Down