From f8f006011d4709f4fe7825c585811a2a33fa7616 Mon Sep 17 00:00:00 2001 From: Mackenzie Clark Date: Mon, 19 Aug 2019 18:48:30 -0700 Subject: [PATCH 1/3] use ctrlc for cross platform signal handling --- Cargo.toml | 2 +- src/bastion.rs | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 27fb1141..24c86642 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ maintenance = { status = "actively-developed" } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +ctrlc = "3.1.3" tokio = "^0.1" tokio-executor = "0.1.8" tokio-threadpool = "0.1.15" @@ -46,7 +47,6 @@ backtrace = "0.3.32" ego-tree = "0.6.0" lazy_static = "1.3.0" objekt = "0.1.2" -signal-hook = "0.1.10" parking_lot = "0.9" diff --git a/src/bastion.rs b/src/bastion.rs index 0e55eaac..44b24df0 100644 --- a/src/bastion.rs +++ b/src/bastion.rs @@ -12,7 +12,6 @@ use env_logger::Builder; use futures::future::poll_fn; use lazy_static::lazy_static; use log::LevelFilter; -use signal_hook::{iterator::Signals, SIGINT}; use std::panic::AssertUnwindSafe; use std::sync::Arc; use parking_lot::Mutex; @@ -329,16 +328,14 @@ impl RuntimeManager for Bastion { fn runtime_shutdown_callback() { let mut entered = tokio_executor::enter().expect("main thread_local runtime lock"); - let signals = Signals::new(&[SIGINT]).unwrap(); - + let running = Arc::new(AtomicBool::new(true)); + let r = running.clone(); + let _ = ctrlc::set_handler(move || { + r.store(false, Ordering::SeqCst); + }).unwrap(); entered .block_on(poll_fn(|| { - for sig in signals.forever() { - match sig { - signal_hook::SIGINT => break, - _ => unreachable!(), - } - } + while running.load(Ordering::SeqCst) {} CLOSE_OVER })) .expect("cannot shutdown"); From d80a3e303da5cfe33d24c008b085616b8b77d970 Mon Sep 17 00:00:00 2001 From: Mackenzie Clark Date: Mon, 19 Aug 2019 18:58:43 -0700 Subject: [PATCH 2/3] create an appveyor file --- .appveyor.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .appveyor.yaml diff --git a/.appveyor.yaml b/.appveyor.yaml new file mode 100644 index 00000000..fd2020f0 --- /dev/null +++ b/.appveyor.yaml @@ -0,0 +1,26 @@ +environment: + matrix: + - TARGET: i686-pc-windows-msvc + CHANNEL: stable + - TARGET: x86_64-pc-windows-gnu + CHANNEL: stable + - TARGET: x86_64-pc-windows-msvc + CHANNEL: stable + - TARGET: i686-pc-windows-msvc + CHANNEL: nightly + - TARGET: x86_64-pc-windows-gnu + CHANNEL: nightly + - TARGET: x86_64-pc-windows-msvc + CHANNEL: nightly + +install: + - curl -sSf -o rustup-init.exe https://win.rustup.rs + - rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\msys64\mingw64\bin;C:\msys64\usr\bin; + - rustc -Vv + - cargo -V + +build: false + +test_script: + - cargo test --release From 328f4c47ea092ce434e5e7966d47b52b9234726b Mon Sep 17 00:00:00 2001 From: Mackenzie Clark Date: Mon, 19 Aug 2019 19:46:05 -0700 Subject: [PATCH 3/3] add missing imports --- src/bastion.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bastion.rs b/src/bastion.rs index 44b24df0..79210b29 100644 --- a/src/bastion.rs +++ b/src/bastion.rs @@ -20,6 +20,7 @@ use tokio::prelude::*; use tokio::runtime::Runtime; use uuid::Uuid; use std::mem; +use std::sync::atomic::{AtomicBool, Ordering}; lazy_static! { // Platform which contains runtime system.