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

Commit 065b0f3

Browse files
authored
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
1 parent e03b8db commit 065b0f3

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/service/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pin-project = "0.4.8"
3939
hash-db = "0.15.2"
4040
serde = "1.0.101"
4141
serde_json = "1.0.41"
42-
sysinfo = "0.14.3"
42+
sysinfo = "0.14.15"
4343
sc-keystore = { version = "2.0.0-rc5", path = "../keystore" }
4444
sp-io = { version = "2.0.0-rc5", path = "../../primitives/io" }
4545
sp-runtime = { version = "2.0.0-rc5", path = "../../primitives/runtime" }

client/service/src/metrics.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl MetricsService {
199199

200200
Self {
201201
metrics,
202-
system: sysinfo::System::new(),
202+
system: sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_processes()),
203203
pid: Some(process.pid),
204204
}
205205
}
@@ -234,7 +234,7 @@ impl MetricsService {
234234
fn inner_new(metrics: Option<PrometheusMetrics>) -> Self {
235235
Self {
236236
metrics,
237-
system: sysinfo::System::new(),
237+
system: sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_processes()),
238238
pid: sysinfo::get_current_pid().ok(),
239239
}
240240
}
@@ -283,12 +283,11 @@ impl MetricsService {
283283
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
284284
fn process_info_for(&mut self, pid: &sysinfo::Pid) -> ProcessInfo {
285285
let mut info = ProcessInfo::default();
286-
if self.system.refresh_process(*pid) {
287-
let prc = self.system.get_process(*pid)
288-
.expect("Above refresh_process succeeds, this must be Some(), qed");
286+
self.system.refresh_process(*pid);
287+
self.system.get_process(*pid).map(|prc| {
289288
info.cpu_usage = prc.cpu_usage().into();
290289
info.memory = prc.memory();
291-
}
290+
});
292291
info
293292
}
294293

0 commit comments

Comments
 (0)