Skip to content

Commit 5675d81

Browse files
authored
other: more traces to debug, update some deps (#264)
Minor update to update some dependencies and remove some traces.
1 parent ba7738e commit 5675d81

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4242

4343
- [#261](https://github.com/ClementTsang/bottom/pull/261): Fixed process names occasionally showing up as truncated, due to only using `/proc/<PID>/stat` as our data source.
4444

45+
- [#262](https://github.com/ClementTsang/bottom/pull/262): Fixed missing thread termination steps as well as improper polling causing blocking in input thread.
46+
4547
## [0.4.7] - 2020-08-26
4648

4749
### Bug Fixes

Cargo.lock

+6-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ codegen-units = 1
2727
anyhow = "1.0.32"
2828
backtrace = "0.3"
2929
battery = "0.7.6"
30-
chrono = "0.4.15"
30+
chrono = "0.4.19"
3131
crossterm = "0.17"
3232
ctrlc = {version = "3.1", features = ["termination"]}
3333
clap = "2.33"
@@ -39,7 +39,7 @@ lazy_static = "1.4.0"
3939
libc = "0.2"
4040
regex = "1.3"
4141
serde = {version = "1.0", features = ["derive"] }
42-
sysinfo = "0.15.1"
42+
sysinfo = "0.15.3"
4343
thiserror = "1.0.20"
4444
toml = "0.5.6"
4545
tui = {version = "0.12.0", features = ["crossterm"], default-features = false }

src/app/data_harvester.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub struct DataCollector {
9494

9595
impl Default for DataCollector {
9696
fn default() -> Self {
97+
trace!("Creating default data collector...");
9798
DataCollector {
9899
data: Data::default(),
99100
sys: System::new_all(),
@@ -114,13 +115,18 @@ impl Default for DataCollector {
114115
battery_manager: None,
115116
battery_list: None,
116117
#[cfg(target_os = "linux")]
117-
page_file_size_kb: unsafe { libc::sysconf(libc::_SC_PAGESIZE) as u64 / 1024 },
118+
page_file_size_kb: unsafe {
119+
let page_file_size_kb = libc::sysconf(libc::_SC_PAGESIZE) as u64 / 1024;
120+
trace!("Page file size in KB: {}", page_file_size_kb);
121+
page_file_size_kb
122+
},
118123
}
119124
}
120125
}
121126

122127
impl DataCollector {
123128
pub fn init(&mut self) {
129+
trace!("Initializing data collector.");
124130
self.mem_total_kb = self.sys.get_total_memory();
125131
trace!("Total memory in KB: {}", self.mem_total_kb);
126132

@@ -139,9 +145,10 @@ impl DataCollector {
139145

140146
trace!("Running first run.");
141147
futures::executor::block_on(self.update_data());
148+
trace!("First run done. Sleeping for 250ms...");
142149
std::thread::sleep(std::time::Duration::from_millis(250));
143150

144-
trace!("Running first run cleanup now.");
151+
trace!("First run done. Running first run cleanup now.");
145152
self.data.cleanup();
146153

147154
trace!("Enabled widgets to harvest: {:#?}", self.widgets_to_harvest);

src/bin/main.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ fn main() -> Result<()> {
7979

8080
// Set up input handling
8181
let (sender, receiver) = mpsc::channel();
82-
let input_thread = create_input_thread(sender.clone(), thread_termination_lock.clone());
82+
let _input_thread = create_input_thread(sender.clone(), thread_termination_lock.clone());
8383

8484
// Cleaning loop
85-
let cleaning_thread = {
85+
let _cleaning_thread = {
8686
let lock = thread_termination_lock.clone();
8787
let cvar = thread_termination_cvar.clone();
8888
let cleaning_sender = sender.clone();
@@ -114,7 +114,7 @@ fn main() -> Result<()> {
114114

115115
// Event loop
116116
let (collection_thread_ctrl_sender, collection_thread_ctrl_receiver) = mpsc::channel();
117-
let collection_thread = create_collection_thread(
117+
let _collection_thread = create_collection_thread(
118118
sender,
119119
collection_thread_ctrl_receiver,
120120
thread_termination_lock.clone(),
@@ -255,13 +255,9 @@ fn main() -> Result<()> {
255255
trace!("Notifying all cvars.");
256256
thread_termination_cvar.notify_all();
257257

258-
cleanup_terminal(&mut terminal, is_debug)?;
259-
260258
trace!("Main/drawing thread is cleaning up.");
259+
cleanup_terminal(&mut terminal, is_debug)?;
261260

262-
cleaning_thread.join().unwrap();
263-
input_thread.join().unwrap();
264-
collection_thread.join().unwrap();
265261
trace!("Fini.");
266262
Ok(())
267263
}

src/clap.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ When searching for a process, enables case sensitivity by default.\n\n",
8888
"\
8989
Enables debug logging. The program will print where it logged to after running.",
9090
);
91+
// TODO: [DIAGNOSE] Add a diagnose option to help with debugging.
9192
let disable_click = Arg::with_name("disable_click")
9293
.long("disable_click")
9394
.help("Disables mouse clicks.")

src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,12 @@ pub fn create_collection_thread(
624624
thread::spawn(move || {
625625
trace!("Spawned collection thread.");
626626
let mut data_state = data_harvester::DataCollector::default();
627-
trace!("Created initial data state.");
627+
trace!("Created default data state.");
628628
data_state.set_collected_data(used_widget_set);
629629
data_state.set_temperature_type(temp_type);
630630
data_state.set_use_current_cpu_total(use_current_cpu_total);
631631
data_state.set_show_average_cpu(show_average_cpu);
632+
trace!("Set default data state settings.");
632633

633634
data_state.init();
634635
trace!("Data state is now fully initialized.");

0 commit comments

Comments
 (0)