mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-20 19:11:09 +03:00
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:
parent
0b491fea0f
commit
c0b7c68b13
5 changed files with 697 additions and 649 deletions
1312
Cargo.lock
generated
1312
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -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();
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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)?;
|
||||
|
|
Loading…
Reference in a new issue