Vendor dependencies
Let's see how I like this workflow.
This commit is contained in:
parent
34d1830413
commit
9c435dc440
7500 changed files with 1665121 additions and 99 deletions
1
vendor/signal-hook-mio/.cargo-checksum.json
vendored
Normal file
1
vendor/signal-hook-mio/.cargo-checksum.json
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"files":{"Cargo.toml":"188f8e22dfa9a88f5e59b163bbeae30b950d8af1a2873116d1542a1d3fc7890b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"503558bfefe66ca15e4e3f7955b3cb0ec87fd52f29bf24b336af7bd00e946d5c","README.md":"e2ac8dfcddf8dec4565f2cd2ee4e4b0aeeeace01fefa857645795083853e2d3f","src/lib.rs":"5ecc2d8a2c3048bd69c2c49b24202f02ada92b13a931a84039823f9b02478aa2","tests/mio_0_6.rs":"82b9a6b48836584abd2a9bd4f8474e357495c952b8fc84c681fa22494341a9dd","tests/mio_0_7.rs":"f5df7c8f3d0d9dee21b51d69a016adc677a8725e64b8de07146bc64270d09b92","tests/mio_0_8.rs":"ae978cda62548259e4a311554d07e2c745c5e9526cc7719bb3a3dc69fcdd1de2"},"package":"29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af"}
|
||||
95
vendor/signal-hook-mio/Cargo.toml
vendored
Normal file
95
vendor/signal-hook-mio/Cargo.toml
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "signal-hook-mio"
|
||||
version = "0.2.3"
|
||||
authors = [
|
||||
"Michal 'vorner' Vaner <vorner@vorner.cz>",
|
||||
"Thomas Himmelstoss <thimm@posteo.de>",
|
||||
]
|
||||
description = "MIO support for signal-hook"
|
||||
documentation = "https://docs.rs/signal-hook-mio"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"signal",
|
||||
"unix",
|
||||
"mio",
|
||||
]
|
||||
license = "Apache-2.0/MIT"
|
||||
repository = "https://github.com/vorner/signal-hook"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = [
|
||||
"--cfg",
|
||||
"docsrs",
|
||||
]
|
||||
|
||||
[dependencies.libc]
|
||||
version = "~0.2"
|
||||
|
||||
[dependencies.mio-0_6]
|
||||
version = "~0.6"
|
||||
optional = true
|
||||
package = "mio"
|
||||
|
||||
[dependencies.mio-0_7]
|
||||
version = "~0.7"
|
||||
features = [
|
||||
"os-util",
|
||||
"uds",
|
||||
]
|
||||
optional = true
|
||||
package = "mio"
|
||||
|
||||
[dependencies.mio-0_8]
|
||||
version = "~0.8"
|
||||
features = [
|
||||
"net",
|
||||
"os-ext",
|
||||
]
|
||||
optional = true
|
||||
package = "mio"
|
||||
|
||||
[dependencies.mio-uds]
|
||||
version = "~0.6"
|
||||
optional = true
|
||||
|
||||
[dependencies.signal-hook]
|
||||
version = "~0.3"
|
||||
|
||||
[dev-dependencies.mio-0_7]
|
||||
version = "~0.7"
|
||||
features = [
|
||||
"os-util",
|
||||
"os-poll",
|
||||
"uds",
|
||||
]
|
||||
package = "mio"
|
||||
|
||||
[dev-dependencies.serial_test]
|
||||
version = "~0.5"
|
||||
|
||||
[features]
|
||||
support-v0_6 = [
|
||||
"mio-0_6",
|
||||
"mio-uds",
|
||||
]
|
||||
support-v0_7 = ["mio-0_7"]
|
||||
support-v0_8 = ["mio-0_8"]
|
||||
|
||||
[badges.maintenance]
|
||||
status = "actively-developed"
|
||||
|
||||
[badges.travis-ci]
|
||||
repository = "vorner/signal-hook"
|
||||
201
vendor/signal-hook-mio/LICENSE-APACHE
vendored
Normal file
201
vendor/signal-hook-mio/LICENSE-APACHE
vendored
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
25
vendor/signal-hook-mio/LICENSE-MIT
vendored
Normal file
25
vendor/signal-hook-mio/LICENSE-MIT
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2017 tokio-jsonrpc developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
23
vendor/signal-hook-mio/README.md
vendored
Normal file
23
vendor/signal-hook-mio/README.md
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# signal-hook-mio
|
||||
|
||||
[](https://travis-ci.org/vorner/signal-hook)
|
||||
|
||||
This is a mio adapter crate for the
|
||||
[signal-hook](https://crates.io/crates/signal-hook) crate. See the
|
||||
[documentation](https://docs.rs/signal-hook-mio) for further details.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of
|
||||
|
||||
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||
|
||||
at your option.
|
||||
|
||||
### Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally
|
||||
submitted for inclusion in the work by you, as defined in the Apache-2.0
|
||||
license, shall be dual licensed as above, without any additional terms
|
||||
or conditions.
|
||||
374
vendor/signal-hook-mio/src/lib.rs
vendored
Normal file
374
vendor/signal-hook-mio/src/lib.rs
vendored
Normal file
|
|
@ -0,0 +1,374 @@
|
|||
#![doc(test(attr(deny(warnings))))]
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
//! A crate offering integration with the MIO runtime.
|
||||
//!
|
||||
//! There are different sub modules for supporting different MIO
|
||||
//! versions. The support for a version must be activated by a
|
||||
//! feature flag:
|
||||
//!
|
||||
//! * `support-v0_6` for sub module [`v0_6`]
|
||||
//! * `support-v0_7` for sub module [`v0_7`]
|
||||
//! * `support-v0_8` for sub module [`v0_8`]
|
||||
//!
|
||||
//! See the specific sub modules for usage examples.
|
||||
|
||||
#[cfg(any(
|
||||
feature = "support-v0_6",
|
||||
feature = "support-v0_7",
|
||||
feature = "support-v0_8"
|
||||
))]
|
||||
macro_rules! implement_signals_with_pipe {
|
||||
($pipe:path) => {
|
||||
use std::borrow::Borrow;
|
||||
use std::io::Error;
|
||||
|
||||
use signal_hook::iterator::backend::{self, SignalDelivery};
|
||||
use signal_hook::iterator::exfiltrator::{Exfiltrator, SignalOnly};
|
||||
|
||||
use $pipe as Pipe;
|
||||
|
||||
use libc::c_int;
|
||||
|
||||
/// A struct which mimics [`signal_hook::iterator::SignalsInfo`]
|
||||
/// but also allows usage together with MIO runtime.
|
||||
pub struct SignalsInfo<E: Exfiltrator = SignalOnly>(SignalDelivery<Pipe, E>);
|
||||
|
||||
pub use backend::Pending;
|
||||
|
||||
impl<E: Exfiltrator> SignalsInfo<E> {
|
||||
/// Create a `Signals` instance.
|
||||
///
|
||||
/// This registers all the signals listed. The same restrictions (panics, errors) apply
|
||||
/// as with [`Handle::add_signal`][backend::Handle::add_signal].
|
||||
pub fn new<I, S>(signals: I) -> Result<Self, Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: Borrow<c_int>,
|
||||
E: Default,
|
||||
{
|
||||
Self::with_exfiltrator(signals, E::default())
|
||||
}
|
||||
|
||||
/// A constructor with specifying an exfiltrator to pass information out of the signal
|
||||
/// handlers.
|
||||
pub fn with_exfiltrator<I, S>(signals: I, exfiltrator: E) -> Result<Self, Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: Borrow<c_int>,
|
||||
{
|
||||
let (read, write) = Pipe::pair()?;
|
||||
let delivery = SignalDelivery::with_pipe(read, write, exfiltrator, signals)?;
|
||||
Ok(Self(delivery))
|
||||
}
|
||||
|
||||
/// Registers another signal to the set watched by this [`Signals`] instance.
|
||||
///
|
||||
/// The same restrictions (panics, errors) apply as with
|
||||
/// [`Handle::add_signal`][backend::Handle::add_signal].
|
||||
pub fn add_signal(&self, signal: c_int) -> Result<(), Error> {
|
||||
self.0.handle().add_signal(signal)
|
||||
}
|
||||
|
||||
/// Returns an iterator of already received signals.
|
||||
///
|
||||
/// This returns an iterator over all the signal numbers of the signals received since last
|
||||
/// time they were read (out of the set registered by this `Signals` instance). Note that they
|
||||
/// are returned in arbitrary order and a signal number is returned only once even if it was
|
||||
/// received multiple times.
|
||||
///
|
||||
/// This method returns immediately (does not block) and may produce an empty iterator if there
|
||||
/// are no signals ready. So you should register an instance of this struct at an instance of
|
||||
/// [`mio::Poll`] to query for readability of the underlying self pipe.
|
||||
pub fn pending(&mut self) -> Pending<E> {
|
||||
self.0.pending()
|
||||
}
|
||||
}
|
||||
|
||||
/// A simplified signal iterator.
|
||||
///
|
||||
/// This is the [`SignalsInfo`], but returning only the signal numbers. This is likely the
|
||||
/// one you want to use.
|
||||
pub type Signals = SignalsInfo<SignalOnly>;
|
||||
};
|
||||
}
|
||||
|
||||
/// A module for integrating signal handling with the MIO 0.8 runtime.
|
||||
///
|
||||
/// This provides the [`Signals`][v0_8::Signals] struct as an abstraction
|
||||
/// which can be used with [`mio::Poll`][mio_0_8::Poll].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use mio_0_8 as mio;
|
||||
/// use std::io::{Error, ErrorKind};
|
||||
///
|
||||
/// use signal_hook::consts::signal::*;
|
||||
/// use signal_hook_mio::v0_8::Signals;
|
||||
///
|
||||
/// use mio::{Events, Poll, Interest, Token};
|
||||
///
|
||||
/// fn main() -> Result<(), Error> {
|
||||
/// let mut poll = Poll::new()?;
|
||||
///
|
||||
/// let mut signals = Signals::new(&[
|
||||
/// SIGTERM,
|
||||
/// # SIGUSR1,
|
||||
/// ])?;
|
||||
///
|
||||
/// let signal_token = Token(0);
|
||||
///
|
||||
/// poll.registry().register(&mut signals, signal_token, Interest::READABLE)?;
|
||||
/// # signal_hook::low_level::raise(SIGUSR1).unwrap(); // Just for terminating the example
|
||||
///
|
||||
/// let mut events = Events::with_capacity(10);
|
||||
/// 'outer: loop {
|
||||
/// poll.poll(&mut events, None)
|
||||
/// .or_else(|e| if e.kind() == ErrorKind::Interrupted {
|
||||
/// // We get interrupt when a signal happens inside poll. That's non-fatal, just
|
||||
/// // retry.
|
||||
/// events.clear();
|
||||
/// Ok(())
|
||||
/// } else {
|
||||
/// Err(e)
|
||||
/// })?;
|
||||
/// for event in events.iter() {
|
||||
/// match event.token() {
|
||||
/// Token(0) => {
|
||||
/// for signal in signals.pending() {
|
||||
/// match signal {
|
||||
/// SIGTERM => break 'outer,
|
||||
/// # SIGUSR1 => return Ok(()),
|
||||
/// _ => unreachable!(),
|
||||
/// }
|
||||
/// }
|
||||
/// },
|
||||
/// _ => unreachable!("Register other sources and match for their tokens here"),
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(feature = "support-v0_8")]
|
||||
pub mod v0_8 {
|
||||
use mio::event::Source;
|
||||
use mio::{Interest, Registry, Token};
|
||||
use mio_0_8 as mio;
|
||||
|
||||
implement_signals_with_pipe!(mio::net::UnixStream);
|
||||
|
||||
impl Source for Signals {
|
||||
fn register(
|
||||
&mut self,
|
||||
registry: &Registry,
|
||||
token: Token,
|
||||
interest: Interest,
|
||||
) -> Result<(), Error> {
|
||||
self.0.get_read_mut().register(registry, token, interest)
|
||||
}
|
||||
|
||||
fn reregister(
|
||||
&mut self,
|
||||
registry: &Registry,
|
||||
token: Token,
|
||||
interest: Interest,
|
||||
) -> Result<(), Error> {
|
||||
self.0.get_read_mut().reregister(registry, token, interest)
|
||||
}
|
||||
|
||||
fn deregister(&mut self, registry: &Registry) -> Result<(), Error> {
|
||||
self.0.get_read_mut().deregister(registry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A module for integrating signal handling with the MIO 0.7 runtime.
|
||||
///
|
||||
/// This provides the [`Signals`][v0_7::Signals] struct as an abstraction
|
||||
/// which can be used with [`mio::Poll`][mio_0_7::Poll].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use mio_0_7 as mio;
|
||||
/// use std::io::{Error, ErrorKind};
|
||||
///
|
||||
/// use signal_hook::consts::signal::*;
|
||||
/// use signal_hook_mio::v0_7::Signals;
|
||||
///
|
||||
/// use mio::{Events, Poll, Interest, Token};
|
||||
///
|
||||
/// fn main() -> Result<(), Error> {
|
||||
/// let mut poll = Poll::new()?;
|
||||
///
|
||||
/// let mut signals = Signals::new(&[
|
||||
/// SIGTERM,
|
||||
/// # SIGUSR1,
|
||||
/// ])?;
|
||||
///
|
||||
/// let signal_token = Token(0);
|
||||
///
|
||||
/// poll.registry().register(&mut signals, signal_token, Interest::READABLE)?;
|
||||
/// # signal_hook::low_level::raise(SIGUSR1).unwrap(); // Just for terminating the example
|
||||
///
|
||||
/// let mut events = Events::with_capacity(10);
|
||||
/// 'outer: loop {
|
||||
/// poll.poll(&mut events, None)
|
||||
/// .or_else(|e| if e.kind() == ErrorKind::Interrupted {
|
||||
/// // We get interrupt when a signal happens inside poll. That's non-fatal, just
|
||||
/// // retry.
|
||||
/// events.clear();
|
||||
/// Ok(())
|
||||
/// } else {
|
||||
/// Err(e)
|
||||
/// })?;
|
||||
/// for event in events.iter() {
|
||||
/// match event.token() {
|
||||
/// Token(0) => {
|
||||
/// for signal in signals.pending() {
|
||||
/// match signal {
|
||||
/// SIGTERM => break 'outer,
|
||||
/// # SIGUSR1 => return Ok(()),
|
||||
/// _ => unreachable!(),
|
||||
/// }
|
||||
/// }
|
||||
/// },
|
||||
/// _ => unreachable!("Register other sources and match for their tokens here"),
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(feature = "support-v0_7")]
|
||||
pub mod v0_7 {
|
||||
use mio::event::Source;
|
||||
use mio::{Interest, Registry, Token};
|
||||
use mio_0_7 as mio;
|
||||
|
||||
implement_signals_with_pipe!(mio::net::UnixStream);
|
||||
|
||||
impl Source for Signals {
|
||||
fn register(
|
||||
&mut self,
|
||||
registry: &Registry,
|
||||
token: Token,
|
||||
interest: Interest,
|
||||
) -> Result<(), Error> {
|
||||
self.0.get_read_mut().register(registry, token, interest)
|
||||
}
|
||||
|
||||
fn reregister(
|
||||
&mut self,
|
||||
registry: &Registry,
|
||||
token: Token,
|
||||
interest: Interest,
|
||||
) -> Result<(), Error> {
|
||||
self.0.get_read_mut().reregister(registry, token, interest)
|
||||
}
|
||||
|
||||
fn deregister(&mut self, registry: &Registry) -> Result<(), Error> {
|
||||
self.0.get_read_mut().deregister(registry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A module for integrating signal handling with the MIO 0.6 runtime.
|
||||
///
|
||||
/// This provides the [`Signals`][v0_6::Signals] struct as an abstraction
|
||||
/// which can be used with [`mio::Poll`][mio_0_6::Poll].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use mio_0_6 as mio;
|
||||
/// use std::io::{Error, ErrorKind};
|
||||
///
|
||||
/// use signal_hook::consts::signal::*;
|
||||
/// use signal_hook_mio::v0_6::Signals;
|
||||
///
|
||||
/// use mio::{Events, Poll, PollOpt, Ready, Token};
|
||||
///
|
||||
/// fn main() -> Result<(), Error> {
|
||||
/// let poll = Poll::new()?;
|
||||
///
|
||||
/// let mut signals = Signals::new(&[
|
||||
/// SIGTERM,
|
||||
/// # SIGUSR1,
|
||||
/// ])?;
|
||||
///
|
||||
/// let signal_token = Token(0);
|
||||
///
|
||||
/// poll.register(&mut signals, signal_token, Ready::readable(), PollOpt::level())?;
|
||||
/// # signal_hook::low_level::raise(SIGUSR1).unwrap(); // Just for terminating the example
|
||||
///
|
||||
/// let mut events = Events::with_capacity(10);
|
||||
/// 'outer: loop {
|
||||
/// poll.poll(&mut events, None)
|
||||
/// .or_else(|e| if e.kind() == ErrorKind::Interrupted {
|
||||
/// // We get interrupt when a signal happens inside poll. That's non-fatal, just
|
||||
/// // retry.
|
||||
/// events.clear();
|
||||
/// Ok(0)
|
||||
/// } else {
|
||||
/// Err(e)
|
||||
/// })?;
|
||||
/// for event in events.iter() {
|
||||
/// match event.token() {
|
||||
/// Token(0) => {
|
||||
/// for signal in signals.pending() {
|
||||
/// match signal {
|
||||
/// SIGTERM => break 'outer,
|
||||
/// # SIGUSR1 => return Ok(()),
|
||||
/// _ => unreachable!(),
|
||||
/// }
|
||||
/// }
|
||||
/// },
|
||||
/// _ => unreachable!("Register other sources and match for their tokens here"),
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(feature = "support-v0_6")]
|
||||
pub mod v0_6 {
|
||||
|
||||
use mio::event::Evented;
|
||||
use mio::{Poll, PollOpt, Ready, Token};
|
||||
use mio_0_6 as mio;
|
||||
|
||||
implement_signals_with_pipe!(mio_uds::UnixStream);
|
||||
|
||||
impl Evented for Signals {
|
||||
fn register(
|
||||
&self,
|
||||
poll: &Poll,
|
||||
token: Token,
|
||||
interest: Ready,
|
||||
opts: PollOpt,
|
||||
) -> Result<(), Error> {
|
||||
self.0.get_read().register(poll, token, interest, opts)
|
||||
}
|
||||
|
||||
fn reregister(
|
||||
&self,
|
||||
poll: &Poll,
|
||||
token: Token,
|
||||
interest: Ready,
|
||||
opts: PollOpt,
|
||||
) -> Result<(), Error> {
|
||||
self.0.get_read().reregister(poll, token, interest, opts)
|
||||
}
|
||||
|
||||
fn deregister(&self, poll: &Poll) -> Result<(), Error> {
|
||||
self.0.get_read().deregister(poll)
|
||||
}
|
||||
}
|
||||
}
|
||||
112
vendor/signal-hook-mio/tests/mio_0_6.rs
vendored
Normal file
112
vendor/signal-hook-mio/tests/mio_0_6.rs
vendored
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#![cfg(feature = "support-v0_6")]
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use mio_0_6::{Events, Poll, PollOpt, Ready, Token};
|
||||
use signal_hook::consts::{SIGUSR1, SIGUSR2};
|
||||
use signal_hook::low_level::raise;
|
||||
use signal_hook_mio::v0_6::Signals;
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
use libc::c_int;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_wakeup() {
|
||||
let mut signals = Signals::new(&[SIGUSR1]).unwrap();
|
||||
let token = Token(0);
|
||||
let poll = Poll::new().unwrap();
|
||||
poll.register(&signals, token, Ready::readable(), PollOpt::level())
|
||||
.unwrap();
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
// The self pipe shouldn't be readable yet
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
|
||||
raise(SIGUSR1).unwrap();
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
let event = events.iter().next().unwrap();
|
||||
assert!(event.readiness().is_readable());
|
||||
assert_eq!(token, event.token());
|
||||
let sig = signals.pending().next().unwrap();
|
||||
assert_eq!(SIGUSR1, sig);
|
||||
|
||||
// The self pipe shouldn't be readable after consuming signals
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_multiple_signals() {
|
||||
let mut signals = Signals::new(&[SIGUSR1, SIGUSR2]).unwrap();
|
||||
let poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.register(&signals, token, Ready::readable(), PollOpt::level())
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
raise(SIGUSR1).unwrap();
|
||||
raise(SIGUSR2).unwrap();
|
||||
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
|
||||
let event = events.iter().next().unwrap();
|
||||
assert!(event.readiness().is_readable());
|
||||
|
||||
let sigs: Vec<c_int> = signals.pending().collect();
|
||||
assert_eq!(2, sigs.len());
|
||||
assert!(sigs.contains(&SIGUSR1));
|
||||
assert!(sigs.contains(&SIGUSR2));
|
||||
|
||||
// The self pipe shouldn't be completely empty after calling pending()
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_parallel_multiple() {
|
||||
let mut signals = Signals::new(&[SIGUSR1]).unwrap();
|
||||
let poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.register(&signals, token, Ready::readable(), PollOpt::level())
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
let thread_done = Arc::new(AtomicBool::new(false));
|
||||
|
||||
let done = Arc::clone(&thread_done);
|
||||
thread::spawn(move || {
|
||||
for _ in 0..10 {
|
||||
// Wait some time to allow main thread to poll
|
||||
thread::sleep(Duration::from_millis(25));
|
||||
raise(SIGUSR1).unwrap();
|
||||
}
|
||||
done.store(true, Ordering::SeqCst);
|
||||
|
||||
// Raise a final signal so the main thread wakes up
|
||||
// if it already called poll.
|
||||
raise(SIGUSR1).unwrap();
|
||||
});
|
||||
|
||||
while !thread_done.load(Ordering::SeqCst) {
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
let event = events.iter().next().unwrap();
|
||||
assert!(event.readiness().is_readable());
|
||||
assert_eq!(SIGUSR1, signals.pending().next().unwrap());
|
||||
}
|
||||
}
|
||||
118
vendor/signal-hook-mio/tests/mio_0_7.rs
vendored
Normal file
118
vendor/signal-hook-mio/tests/mio_0_7.rs
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
#![cfg(feature = "support-v0_7")]
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use mio_0_7::{Events, Interest, Poll, Token};
|
||||
|
||||
use signal_hook::consts::{SIGUSR1, SIGUSR2};
|
||||
use signal_hook::low_level::raise;
|
||||
use signal_hook_mio::v0_7::Signals;
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
use libc::c_int;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_wakeup() {
|
||||
let mut signals = Signals::new(&[SIGUSR1]).unwrap();
|
||||
let mut poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.registry()
|
||||
.register(&mut signals, token, Interest::READABLE)
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
// The self pipe shouldn't be readable yet
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
|
||||
raise(SIGUSR1).unwrap();
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
let event = events.iter().next().unwrap();
|
||||
|
||||
assert!(event.is_readable());
|
||||
assert_eq!(token, event.token());
|
||||
let sig = signals.pending().next().unwrap();
|
||||
assert_eq!(SIGUSR1, sig);
|
||||
|
||||
// The self pipe shouldn't be readable after consuming signals
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_multiple_signals() {
|
||||
let mut signals = Signals::new(&[SIGUSR1, SIGUSR2]).unwrap();
|
||||
let mut poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.registry()
|
||||
.register(&mut signals, token, Interest::READABLE)
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
raise(SIGUSR1).unwrap();
|
||||
raise(SIGUSR2).unwrap();
|
||||
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
|
||||
let event = events.iter().next().unwrap();
|
||||
assert!(event.is_readable());
|
||||
|
||||
let sigs: Vec<c_int> = signals.pending().collect();
|
||||
assert_eq!(2, sigs.len());
|
||||
assert!(sigs.contains(&SIGUSR1));
|
||||
assert!(sigs.contains(&SIGUSR2));
|
||||
|
||||
// The self pipe shouldn't be completely empty after calling pending()
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_parallel_multiple() {
|
||||
let mut signals = Signals::new(&[SIGUSR1]).unwrap();
|
||||
let mut poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.registry()
|
||||
.register(&mut signals, token, Interest::READABLE)
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
let thread_done = Arc::new(AtomicBool::new(false));
|
||||
|
||||
let done = Arc::clone(&thread_done);
|
||||
thread::spawn(move || {
|
||||
for _ in 0..10 {
|
||||
// Wait some time to allow main thread to poll
|
||||
thread::sleep(Duration::from_millis(25));
|
||||
raise(SIGUSR1).unwrap();
|
||||
}
|
||||
done.store(true, Ordering::SeqCst);
|
||||
|
||||
// Raise a final signal so the main thread wakes up
|
||||
// if it already called poll.
|
||||
raise(SIGUSR1).unwrap();
|
||||
});
|
||||
|
||||
while !thread_done.load(Ordering::SeqCst) {
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
let event = events.iter().next().unwrap();
|
||||
assert!(event.is_readable());
|
||||
assert_eq!(SIGUSR1, signals.pending().next().unwrap());
|
||||
}
|
||||
}
|
||||
118
vendor/signal-hook-mio/tests/mio_0_8.rs
vendored
Normal file
118
vendor/signal-hook-mio/tests/mio_0_8.rs
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
#![cfg(feature = "support-v0_8")]
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use mio_0_8::{Events, Interest, Poll, Token};
|
||||
|
||||
use signal_hook::consts::{SIGUSR1, SIGUSR2};
|
||||
use signal_hook::low_level::raise;
|
||||
use signal_hook_mio::v0_8::Signals;
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
use libc::c_int;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_wakeup() {
|
||||
let mut signals = Signals::new(&[SIGUSR1]).unwrap();
|
||||
let mut poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.registry()
|
||||
.register(&mut signals, token, Interest::READABLE)
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
// The self pipe shouldn't be readable yet
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
|
||||
raise(SIGUSR1).unwrap();
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
let event = events.iter().next().unwrap();
|
||||
|
||||
assert!(event.is_readable());
|
||||
assert_eq!(token, event.token());
|
||||
let sig = signals.pending().next().unwrap();
|
||||
assert_eq!(SIGUSR1, sig);
|
||||
|
||||
// The self pipe shouldn't be readable after consuming signals
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_multiple_signals() {
|
||||
let mut signals = Signals::new(&[SIGUSR1, SIGUSR2]).unwrap();
|
||||
let mut poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.registry()
|
||||
.register(&mut signals, token, Interest::READABLE)
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
raise(SIGUSR1).unwrap();
|
||||
raise(SIGUSR2).unwrap();
|
||||
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
|
||||
let event = events.iter().next().unwrap();
|
||||
assert!(event.is_readable());
|
||||
|
||||
let sigs: Vec<c_int> = signals.pending().collect();
|
||||
assert_eq!(2, sigs.len());
|
||||
assert!(sigs.contains(&SIGUSR1));
|
||||
assert!(sigs.contains(&SIGUSR2));
|
||||
|
||||
// The self pipe shouldn't be completely empty after calling pending()
|
||||
poll.poll(&mut events, Some(Duration::from_secs(0)))
|
||||
.unwrap();
|
||||
assert!(events.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn mio_parallel_multiple() {
|
||||
let mut signals = Signals::new(&[SIGUSR1]).unwrap();
|
||||
let mut poll = Poll::new().unwrap();
|
||||
let token = Token(0);
|
||||
poll.registry()
|
||||
.register(&mut signals, token, Interest::READABLE)
|
||||
.unwrap();
|
||||
|
||||
let mut events = Events::with_capacity(10);
|
||||
|
||||
let thread_done = Arc::new(AtomicBool::new(false));
|
||||
|
||||
let done = Arc::clone(&thread_done);
|
||||
thread::spawn(move || {
|
||||
for _ in 0..10 {
|
||||
// Wait some time to allow main thread to poll
|
||||
thread::sleep(Duration::from_millis(25));
|
||||
raise(SIGUSR1).unwrap();
|
||||
}
|
||||
done.store(true, Ordering::SeqCst);
|
||||
|
||||
// Raise a final signal so the main thread wakes up
|
||||
// if it already called poll.
|
||||
raise(SIGUSR1).unwrap();
|
||||
});
|
||||
|
||||
while !thread_done.load(Ordering::SeqCst) {
|
||||
poll.poll(&mut events, Some(Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
let event = events.iter().next().unwrap();
|
||||
assert!(event.is_readable());
|
||||
assert_eq!(SIGUSR1, signals.pending().next().unwrap());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue