Merge branch 'mio-0.7.3' of https://github.com/fakeshadow/actix-net into mio-0.7.3

This commit is contained in:
fakeshadow 2020-11-30 00:33:11 +08:00
commit a94270a683
8 changed files with 40 additions and 41 deletions

View File

@ -17,10 +17,9 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix-macros = "0.1.0" actix-macros = "0.1.0"
actix-threadpool = "0.3"
futures-channel = { version = "0.3.4", default-features = false }
futures-util = { version = "0.3.4", default-features = false, features = ["alloc"] }
copyless = "0.1.4" copyless = "0.1.4"
futures-channel = "0.3.4"
futures-util = { version = "0.3.4", default-features = false, features = ["alloc"] }
smallvec = "1" smallvec = "1"
tokio = { version = "0.3.1", features = ["rt", "net", "signal", "stream", "time"] } tokio = { version = "0.3.1", features = ["rt", "net", "signal", "stream", "time"] }

View File

@ -134,10 +134,7 @@ impl Arbiter {
.unbounded_send(SystemCommand::RegisterArbiter(id, arb)); .unbounded_send(SystemCommand::RegisterArbiter(id, arb));
// run loop // run loop
let _ = match rt.block_on(stop_rx) { let _ = rt.block_on(stop_rx).unwrap_or(1);
Ok(code) => code,
Err(_) => 1,
};
// unregister arbiter // unregister arbiter
let _ = System::current() let _ = System::current()

View File

@ -14,9 +14,6 @@ pub use self::builder::{Builder, SystemRunner};
pub use self::runtime::Runtime; pub use self::runtime::Runtime;
pub use self::system::System; pub use self::system::System;
#[doc(hidden)]
pub use actix_threadpool as blocking;
/// Spawns a future on the current arbiter. /// Spawns a future on the current arbiter.
/// ///
/// # Panics /// # Panics

View File

@ -8,6 +8,9 @@
* Remove `AcceptNotify` type and pass `WakerQueue` to `Worker` for wake up the `Accept`'s `Poll`. * Remove `AcceptNotify` type and pass `WakerQueue` to `Worker` for wake up the `Accept`'s `Poll`.
* Convert `mio::net::TcpStream` to `actix_rt::net::TcpStream`(`UnixStream` for uds) using `FromRawFd` and `IntoRawFd`(`FromRawSocket` and `IntoRawSocket` on windows). * Convert `mio::net::TcpStream` to `actix_rt::net::TcpStream`(`UnixStream` for uds) using `FromRawFd` and `IntoRawFd`(`FromRawSocket` and `IntoRawSocket` on windows).
* Remove `AsyncRead` and `AsyncWrite` trait bound for `socket::FromStream` trait. * Remove `AsyncRead` and `AsyncWrite` trait bound for `socket::FromStream` trait.
* Added explicit info log message on accept queue pause. [#215]
[#215]: https://github.com/actix/actix-net/pull/215
## 1.0.4 - 2020-09-12 ## 1.0.4 - 2020-09-12
* Update actix-codec to 0.3.0. * Update actix-codec to 0.3.0.

View File

@ -268,6 +268,7 @@ impl Accept {
fn deregister_all(&self, sockets: &mut Slab<ServerSocketInfo>) { fn deregister_all(&self, sockets: &mut Slab<ServerSocketInfo>) {
sockets.iter_mut().for_each(|(_, info)| { sockets.iter_mut().for_each(|(_, info)| {
info!("Accepting connections on {} has been paused", info.addr);
let _ = self.deregister(info); let _ = self.deregister(info);
}); });
} }

View File

@ -70,7 +70,7 @@ where
/// timeout: Duration, /// timeout: Duration,
/// } /// }
/// ///
/// impl<S> Transform<S> for TimeoutTransform<E> /// impl<S> Transform<S> for TimeoutTransform
/// where /// where
/// S: Service, /// S: Service,
/// { /// {

View File

@ -167,13 +167,13 @@ impl ResourceDef {
/// Is prefix path a match against this resource. /// Is prefix path a match against this resource.
pub fn is_prefix_match(&self, path: &str) -> Option<usize> { pub fn is_prefix_match(&self, path: &str) -> Option<usize> {
let plen = path.len(); let p_len = path.len();
let path = if path.is_empty() { "/" } else { path }; let path = if path.is_empty() { "/" } else { path };
match self.tp { match self.tp {
PatternType::Static(ref s) => { PatternType::Static(ref s) => {
if s == path { if s == path {
Some(plen) Some(p_len)
} else { } else {
None None
} }
@ -211,7 +211,7 @@ impl ResourceDef {
} else { } else {
return None; return None;
}; };
Some(min(plen, len)) Some(min(p_len, len))
} }
PatternType::DynamicSet(ref re, ref params) => { PatternType::DynamicSet(ref re, ref params) => {
if let Some(idx) = re.matches(path).into_iter().next() { if let Some(idx) = re.matches(path).into_iter().next() {
@ -252,11 +252,11 @@ impl ResourceDef {
} }
} }
PatternType::Prefix(ref s) => { PatternType::Prefix(ref s) => {
let rpath = path.path(); let r_path = path.path();
let len = if s == rpath { let len = if s == r_path {
s.len() s.len()
} else if rpath.starts_with(s) } else if r_path.starts_with(s)
&& (s.ends_with('/') || rpath.split_at(s.len()).1.starts_with('/')) && (s.ends_with('/') || r_path.split_at(s.len()).1.starts_with('/'))
{ {
if s.ends_with('/') { if s.ends_with('/') {
s.len() - 1 s.len() - 1
@ -266,8 +266,8 @@ impl ResourceDef {
} else { } else {
return false; return false;
}; };
let rpath_len = rpath.len(); let r_path_len = r_path.len();
path.skip(min(rpath_len, len) as u16); path.skip(min(r_path_len, len) as u16);
true true
} }
PatternType::Dynamic(ref re, ref names, len) => { PatternType::Dynamic(ref re, ref names, len) => {
@ -361,11 +361,11 @@ impl ResourceDef {
} }
PatternType::Prefix(ref s) => { PatternType::Prefix(ref s) => {
let len = { let len = {
let rpath = res.resource_path().path(); let r_path = res.resource_path().path();
if s == rpath { if s == r_path {
s.len() s.len()
} else if rpath.starts_with(s) } else if r_path.starts_with(s)
&& (s.ends_with('/') || rpath.split_at(s.len()).1.starts_with('/')) && (s.ends_with('/') || r_path.split_at(s.len()).1.starts_with('/'))
{ {
if s.ends_with('/') { if s.ends_with('/') {
s.len() - 1 s.len() - 1
@ -580,6 +580,8 @@ impl ResourceDef {
mut for_prefix: bool, mut for_prefix: bool,
) -> (String, Vec<PatternElement>, bool, usize) { ) -> (String, Vec<PatternElement>, bool, usize) {
if pattern.find('{').is_none() { if pattern.find('{').is_none() {
// TODO: MSRV: 1.45
#[allow(clippy::manual_strip)]
return if pattern.ends_with('*') { return if pattern.ends_with('*') {
let path = &pattern[..pattern.len() - 1]; let path = &pattern[..pattern.len() - 1];
let re = String::from("^") + path + "(.*)"; let re = String::from("^") + path + "(.*)";
@ -594,39 +596,39 @@ impl ResourceDef {
}; };
} }
let mut elems = Vec::new(); let mut elements = Vec::new();
let mut re = String::from("^"); let mut re = String::from("^");
let mut dyn_elems = 0; let mut dyn_elements = 0;
while let Some(idx) = pattern.find('{') { while let Some(idx) = pattern.find('{') {
let (prefix, rem) = pattern.split_at(idx); let (prefix, rem) = pattern.split_at(idx);
elems.push(PatternElement::Str(String::from(prefix))); elements.push(PatternElement::Str(String::from(prefix)));
re.push_str(&escape(prefix)); re.push_str(&escape(prefix));
let (param_pattern, re_part, rem, tail) = Self::parse_param(rem); let (param_pattern, re_part, rem, tail) = Self::parse_param(rem);
if tail { if tail {
for_prefix = true; for_prefix = true;
} }
elems.push(param_pattern); elements.push(param_pattern);
re.push_str(&re_part); re.push_str(&re_part);
pattern = rem; pattern = rem;
dyn_elems += 1; dyn_elements += 1;
} }
elems.push(PatternElement::Str(String::from(pattern))); elements.push(PatternElement::Str(String::from(pattern)));
re.push_str(&escape(pattern)); re.push_str(&escape(pattern));
if dyn_elems > MAX_DYNAMIC_SEGMENTS { if dyn_elements > MAX_DYNAMIC_SEGMENTS {
panic!( panic!(
"Only {} dynanic segments are allowed, provided: {}", "Only {} dynamic segments are allowed, provided: {}",
MAX_DYNAMIC_SEGMENTS, dyn_elems MAX_DYNAMIC_SEGMENTS, dyn_elements
); );
} }
if !for_prefix { if !for_prefix {
re.push('$'); re.push('$');
} }
(re, elems, true, pattern.chars().count()) (re, elements, true, pattern.chars().count())
} }
} }
@ -718,10 +720,10 @@ mod tests {
assert!(!re.is_match("/v/resource/1")); assert!(!re.is_match("/v/resource/1"));
assert!(!re.is_match("/resource")); assert!(!re.is_match("/resource"));
let mut path = Path::new("/v151/resource/adahg32"); let mut path = Path::new("/v151/resource/adage32");
assert!(re.match_path(&mut path)); assert!(re.match_path(&mut path));
assert_eq!(path.get("version").unwrap(), "151"); assert_eq!(path.get("version").unwrap(), "151");
assert_eq!(path.get("id").unwrap(), "adahg32"); assert_eq!(path.get("id").unwrap(), "adage32");
let re = ResourceDef::new("/{id:[[:digit:]]{6}}"); let re = ResourceDef::new("/{id:[[:digit:]]{6}}");
assert!(re.is_match("/012345")); assert!(re.is_match("/012345"));
@ -759,10 +761,10 @@ mod tests {
assert!(!re.is_match("/v/resource/1")); assert!(!re.is_match("/v/resource/1"));
assert!(!re.is_match("/resource")); assert!(!re.is_match("/resource"));
let mut path = Path::new("/v151/resource/adahg32"); let mut path = Path::new("/v151/resource/adage32");
assert!(re.match_path(&mut path)); assert!(re.match_path(&mut path));
assert_eq!(path.get("version").unwrap(), "151"); assert_eq!(path.get("version").unwrap(), "151");
assert_eq!(path.get("id").unwrap(), "adahg32"); assert_eq!(path.get("id").unwrap(), "adage32");
assert!(re.is_match("/012345")); assert!(re.is_match("/012345"));
assert!(!re.is_match("/012")); assert!(!re.is_match("/012"));

View File

@ -182,11 +182,11 @@ impl Quoter {
#[inline] #[inline]
fn from_hex(v: u8) -> Option<u8> { fn from_hex(v: u8) -> Option<u8> {
if v >= b'0' && v <= b'9' { if (b'0'..=b'9').contains(&v) {
Some(v - 0x30) // ord('0') == 0x30 Some(v - 0x30) // ord('0') == 0x30
} else if v >= b'A' && v <= b'F' { } else if (b'A'..=b'F').contains(&v) {
Some(v - 0x41 + 10) // ord('A') == 0x41 Some(v - 0x41 + 10) // ord('A') == 0x41
} else if v >= b'a' && v <= b'f' { } else if (b'a'..=b'f').contains(&v) {
Some(v - 0x61 + 10) // ord('a') == 0x61 Some(v - 0x61 + 10) // ord('a') == 0x61
} else { } else {
None None