Update to latest sysinfo prevents leaking fd-handlers (#6708)

* Ensure we close old file handles hold by sysinfo

* Dropping is needed unfortunately

* enable process refreshing, ignore result from refresh_process

* jumping to proposed patch

* switch to latest sysinfo
This commit is contained in:
Benjamin Kampmann
2020-07-22 17:48:12 +02:00
committed by GitHub
parent c4dd079119
commit 7c161ec177
3 changed files with 8 additions and 9 deletions
+2 -2
View File
@@ -8815,9 +8815,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.14.13"
version = "0.14.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eec476c3d107e7fc2c445e4edc26836c49ba5be0dae74146ee94ecb62759c31d"
checksum = "2983daff11a197c7c406b130579bc362177aa54cf2cc1f34d6ac88fccaa6a5e1"
dependencies = [
"cfg-if",
"doc-comment",
+1 -1
View File
@@ -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" }
+5 -6
View File
@@ -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),
}
}
@@ -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(),
}
}
@@ -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
}