Update sysinfo crate to 0.29.6 (#685)

* update sysinfo package to fix build error

* update tor process sysinfo calls to new api

* update deprecation warnings

* small logic cleanup

* tweak to retrigger CI

* new_all() not required

* give longer for test thread to stop to hopefully alleviate inconsistent CI failures
This commit is contained in:
Yeastplume 2023-07-26 12:59:36 +01:00 committed by GitHub
parent 0b491fea0f
commit c0b7c68b13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 697 additions and 649 deletions

1312
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -508,8 +508,8 @@ where
.1
.into_iter()
.map(|mut t| {
t.confirmation_ts = Some(Utc.ymd(2019, 1, 15).and_hms(16, 1, 26));
t.creation_ts = Utc.ymd(2019, 1, 15).and_hms(16, 1, 26);
t.confirmation_ts = Some(Utc.with_ymd_and_hms(2019, 1, 15, 16, 1, 26).unwrap());
t.creation_ts = Utc.with_ymd_and_hms(2019, 1, 15, 16, 1, 26).unwrap();
t
})
.collect();

View file

@ -133,7 +133,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
thread::sleep(Duration::from_millis(1000));
Ok(())
}

View file

@ -32,7 +32,7 @@ x25519-dalek = "0.6"
data-encoding = "2"
regex = "1.3"
timer = "0.2"
sysinfo = "0.14"
sysinfo = "0.29"
base64 = "0.12.0"
url = "2.1"

View file

@ -58,7 +58,7 @@ use std::path::{Path, MAIN_SEPARATOR};
use std::process::{Child, ChildStdout, Command, Stdio};
use std::sync::mpsc::channel;
use std::thread;
use sysinfo::{Process, ProcessExt, Signal};
use sysinfo::{Process, ProcessExt, System, SystemExt};
#[cfg(windows)]
const TOR_EXE_NAME: &str = "tor.exe";
@ -78,16 +78,6 @@ pub enum Error {
Timeout,
}
#[cfg(windows)]
fn get_process(pid: i32) -> Process {
Process::new(pid as usize, None, 0)
}
#[cfg(not(windows))]
fn get_process(pid: i32) -> Process {
Process::new(pid, None, 0)
}
pub struct TorProcess {
tor_cmd: String,
args: Vec<String>,
@ -97,6 +87,7 @@ pub struct TorProcess {
working_dir: Option<String>,
pub stdout: Option<BufReader<ChildStdout>>,
pub process: Option<Child>,
sys: System,
}
impl TorProcess {
@ -110,9 +101,15 @@ impl TorProcess {
working_dir: None,
stdout: None,
process: None,
sys: System::new(),
}
}
fn get_process(&mut self, pid: i32) -> Option<&Process> {
self.sys.refresh_all();
self.sys.process((pid as usize).into())
}
pub fn tor_cmd(&mut self, tor_cmd: &str) -> &mut Self {
self.tor_cmd = tor_cmd.to_string();
self
@ -164,8 +161,9 @@ impl TorProcess {
let pid = pid
.parse::<i32>()
.map_err(|err| Error::PID(format!("{:?}", err)))?;
let process = get_process(pid);
let _ = process.kill(Signal::Kill);
if let Some(p) = self.get_process(pid) {
let _ = p.kill();
}
}
}
if let Some(ref torrc_path) = self.torrc_path {
@ -183,7 +181,7 @@ impl TorProcess {
})?;
if let Some(ref d) = self.working_dir {
// split out the process id, so if we don't exit cleanly
// Split out the process id, so if we don't exit cleanly
// we can take it down on the next run
let pid_file_name = format!("{}{}pid", d, MAIN_SEPARATOR);
let mut file = File::create(pid_file_name).map_err(Error::IO)?;