signal: Smaller dependency (#1069)

The signal-hook library got split into lower-level and higher-level
parts. The tokio-signal uses only API from the lower-level one, so it
can depend on it directly.

The only effect of this change is smaller amount of compiled (and
unused) code during compilation. There's no change in the code actually
used.
This commit is contained in:
Michal 'vorner' Vaner
2019-04-28 19:12:40 -07:00
committed by Ivan Petkov
parent 927eb80ad4
commit 042224d33c
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ tokio-io = "0.1"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
mio-uds = "0.6"
signal-hook = "0.1"
signal-hook-registry = "~1"
[dev-dependencies]
tokio = "0.1.8"
+4 -3
View File
@@ -8,7 +8,7 @@
pub extern crate libc;
extern crate mio;
extern crate mio_uds;
extern crate signal_hook;
extern crate signal_hook_registry;
use std::io::prelude::*;
use std::io::{self, Error, ErrorKind};
@@ -153,7 +153,7 @@ fn action(slot: &SignalInfo, mut sender: &UnixStream) {
/// This will register the signal handler if it hasn't already been registered,
/// returning any error along the way if that fails.
fn signal_enable(signal: c_int) -> io::Result<()> {
if signal_hook::FORBIDDEN.contains(&signal) {
if signal_hook_registry::FORBIDDEN.contains(&signal) {
return Err(Error::new(
ErrorKind::Other,
format!("Refusing to register signal {}", signal),
@@ -168,7 +168,8 @@ fn signal_enable(signal: c_int) -> io::Result<()> {
let mut registered = Ok(());
siginfo.init.call_once(|| {
registered = unsafe {
signal_hook::register(signal, move || action(siginfo, &globals.sender)).map(|_| ())
signal_hook_registry::register(signal, move || action(siginfo, &globals.sender))
.map(|_| ())
};
if registered.is_ok() {
siginfo.initialized.store(true, Ordering::Relaxed);