From 5675d8192cbe94d7dbc3370315396a11a3aca02e Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Fri, 2 Oct 2020 22:12:07 -0400 Subject: other: more traces to debug, update some deps (#264) Minor update to update some dependencies and remove some traces. --- CHANGELOG.md | 2 ++ Cargo.lock | 10 ++++++---- Cargo.toml | 4 ++-- src/app/data_harvester.rs | 11 +++++++++-- src/bin/main.rs | 12 ++++-------- src/clap.rs | 1 + src/lib.rs | 3 ++- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f3ad2f3..cbec6971 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#261](https://github.com/ClementTsang/bottom/pull/261): Fixed process names occasionally showing up as truncated, due to only using `/proc//stat` as our data source. +- [#262](https://github.com/ClementTsang/bottom/pull/262): Fixed missing thread termination steps as well as improper polling causing blocking in input thread. + ## [0.4.7] - 2020-08-26 ### Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index 5a3b220b..2fdd20c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,13 +194,15 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "chrono" -version = "0.4.15" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942f72db697d8767c22d46a598e01f2d3b475501ea43d0db4f16d90259182d0b" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ + "libc", "num-integer", "num-traits", "time", + "winapi 0.3.9", ] [[package]] @@ -1276,9 +1278,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.15.1" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13816d558f404113dfdf855ed982f160cf697b3e573a68b2b798062032182212" +checksum = "67330cbee3b2a819e3365a773f05e884a136603687f812bf24db5b6c3d76b696" dependencies = [ "cfg-if", "doc-comment", diff --git a/Cargo.toml b/Cargo.toml index 7014597e..a8d8f064 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ codegen-units = 1 anyhow = "1.0.32" backtrace = "0.3" battery = "0.7.6" -chrono = "0.4.15" +chrono = "0.4.19" crossterm = "0.17" ctrlc = {version = "3.1", features = ["termination"]} clap = "2.33" @@ -39,7 +39,7 @@ lazy_static = "1.4.0" libc = "0.2" regex = "1.3" serde = {version = "1.0", features = ["derive"] } -sysinfo = "0.15.1" +sysinfo = "0.15.3" thiserror = "1.0.20" toml = "0.5.6" tui = {version = "0.12.0", features = ["crossterm"], default-features = false } diff --git a/src/app/data_harvester.rs b/src/app/data_harvester.rs index 285c4823..2e46559a 100644 --- a/src/app/data_harvester.rs +++ b/src/app/data_harvester.rs @@ -94,6 +94,7 @@ pub struct DataCollector { impl Default for DataCollector { fn default() -> Self { + trace!("Creating default data collector..."); DataCollector { data: Data::default(), sys: System::new_all(), @@ -114,13 +115,18 @@ impl Default for DataCollector { battery_manager: None, battery_list: None, #[cfg(target_os = "linux")] - page_file_size_kb: unsafe { libc::sysconf(libc::_SC_PAGESIZE) as u64 / 1024 }, + page_file_size_kb: unsafe { + let page_file_size_kb = libc::sysconf(libc::_SC_PAGESIZE) as u64 / 1024; + trace!("Page file size in KB: {}", page_file_size_kb); + page_file_size_kb + }, } } } impl DataCollector { pub fn init(&mut self) { + trace!("Initializing data collector."); self.mem_total_kb = self.sys.get_total_memory(); trace!("Total memory in KB: {}", self.mem_total_kb); @@ -139,9 +145,10 @@ impl DataCollector { trace!("Running first run."); futures::executor::block_on(self.update_data()); + trace!("First run done. Sleeping for 250ms..."); std::thread::sleep(std::time::Duration::from_millis(250)); - trace!("Running first run cleanup now."); + trace!("First run done. Running first run cleanup now."); self.data.cleanup(); trace!("Enabled widgets to harvest: {:#?}", self.widgets_to_harvest); diff --git a/src/bin/main.rs b/src/bin/main.rs index 1df99ab4..8db05b22 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -79,10 +79,10 @@ fn main() -> Result<()> { // Set up input handling let (sender, receiver) = mpsc::channel(); - let input_thread = create_input_thread(sender.clone(), thread_termination_lock.clone()); + let _input_thread = create_input_thread(sender.clone(), thread_termination_lock.clone()); // Cleaning loop - let cleaning_thread = { + let _cleaning_thread = { let lock = thread_termination_lock.clone(); let cvar = thread_termination_cvar.clone(); let cleaning_sender = sender.clone(); @@ -114,7 +114,7 @@ fn main() -> Result<()> { // Event loop let (collection_thread_ctrl_sender, collection_thread_ctrl_receiver) = mpsc::channel(); - let collection_thread = create_collection_thread( + let _collection_thread = create_collection_thread( sender, collection_thread_ctrl_receiver, thread_termination_lock.clone(), @@ -255,13 +255,9 @@ fn main() -> Result<()> { trace!("Notifying all cvars."); thread_termination_cvar.notify_all(); - cleanup_terminal(&mut terminal, is_debug)?; - trace!("Main/drawing thread is cleaning up."); + cleanup_terminal(&mut terminal, is_debug)?; - cleaning_thread.join().unwrap(); - input_thread.join().unwrap(); - collection_thread.join().unwrap(); trace!("Fini."); Ok(()) } diff --git a/src/clap.rs b/src/clap.rs index b9898198..2a03e9b4 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -88,6 +88,7 @@ When searching for a process, enables case sensitivity by default.\n\n", "\ Enables debug logging. The program will print where it logged to after running.", ); + // TODO: [DIAGNOSE] Add a diagnose option to help with debugging. let disable_click = Arg::with_name("disable_click") .long("disable_click") .help("Disables mouse clicks.") diff --git a/src/lib.rs b/src/lib.rs index 54fdb35b..dbcd96f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -624,11 +624,12 @@ pub fn create_collection_thread( thread::spawn(move || { trace!("Spawned collection thread."); let mut data_state = data_harvester::DataCollector::default(); - trace!("Created initial data state."); + trace!("Created default data state."); data_state.set_collected_data(used_widget_set); data_state.set_temperature_type(temp_type); data_state.set_use_current_cpu_total(use_current_cpu_total); data_state.set_show_average_cpu(show_average_cpu); + trace!("Set default data state settings."); data_state.init(); trace!("Data state is now fully initialized."); -- cgit v1.2.3