Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update to latest sysinfo prevents leaking fd-handlers #6708

Merged
5 commits merged into from
Jul 22, 2020
Merged
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pin-project = "0.4.8"
hash-db = "0.15.2"
serde = "1.0.101"
serde_json = "1.0.41"
sysinfo = "0.14.3"
sysinfo = "0.14.15"
sc-keystore = { version = "2.0.0-rc5", path = "../keystore" }
sp-io = { version = "2.0.0-rc5", path = "../../primitives/io" }
sp-runtime = { version = "2.0.0-rc5", path = "../../primitives/runtime" }
Expand Down
11 changes: 5 additions & 6 deletions client/service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl MetricsService {

Self {
metrics,
system: sysinfo::System::new(),
system: sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_processes()),
pid: Some(process.pid),
}
}
Expand Down Expand Up @@ -234,7 +234,7 @@ impl MetricsService {
fn inner_new(metrics: Option<PrometheusMetrics>) -> Self {
Self {
metrics,
system: sysinfo::System::new(),
system: sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_processes()),
pid: sysinfo::get_current_pid().ok(),
}
}
Expand Down Expand Up @@ -283,12 +283,11 @@ impl MetricsService {
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
fn process_info_for(&mut self, pid: &sysinfo::Pid) -> ProcessInfo {
let mut info = ProcessInfo::default();
if self.system.refresh_process(*pid) {
let prc = self.system.get_process(*pid)
.expect("Above refresh_process succeeds, this must be Some(), qed");
self.system.refresh_process(*pid);
self.system.get_process(*pid).map(|prc| {
info.cpu_usage = prc.cpu_usage().into();
info.memory = prc.memory();
}
});
info
}

Expand Down