mirror of https://github.com/fafhrd91/actix-net
Merge branch 'master' into mio-0.7.3
This commit is contained in:
commit
2600f22135
|
@ -9,8 +9,10 @@
|
||||||
//! [`Sink`]: futures_sink::Sink
|
//! [`Sink`]: futures_sink::Sink
|
||||||
//! [`Stream`]: futures_core::Stream
|
//! [`Stream`]: futures_core::Stream
|
||||||
|
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
mod bcodec;
|
mod bcodec;
|
||||||
mod framed;
|
mod framed;
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
//! * `openssl` - enables TLS support via `openssl` crate
|
//! * `openssl` - enables TLS support via `openssl` crate
|
||||||
//! * `rustls` - enables TLS support via `rustls` crate
|
//! * `rustls` - enables TLS support via `rustls` crate
|
||||||
|
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
#![recursion_limit = "128"]
|
#![recursion_limit = "128"]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
//! Macros for use with Tokio
|
//! Macros for use with Tokio
|
||||||
extern crate proc_macro;
|
|
||||||
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
//! A runtime implementation that runs everything on the current thread.
|
//! A runtime implementation that runs everything on the current thread.
|
||||||
#![forbid(unsafe_code)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![allow(clippy::type_complexity)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
#[cfg(not(test))] // Work around for rust-lang/rust#62127
|
#[cfg(not(test))] // Work around for rust-lang/rust#62127
|
||||||
pub use actix_macros::{main, test};
|
pub use actix_macros::{main, test};
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
* 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]
|
* Added explicit info log message on accept queue pause. [#215]
|
||||||
|
* Prevent double registration of sockets when back-pressure is resolved. [#223]
|
||||||
|
|
||||||
|
[#215]: https://github.com/actix/actix-net/pull/215
|
||||||
|
[#223]: https://github.com/actix/actix-net/pull/223
|
||||||
|
|
||||||
[#215]: https://github.com/actix/actix-net/pull/215
|
[#215]: https://github.com/actix/actix-net/pull/215
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,8 @@ use futures_util::future::ready;
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
use crate::builder::bind_addr;
|
use crate::builder::bind_addr;
|
||||||
use crate::service::{
|
use crate::service::{BoxedServerService, InternalServiceFactory, StreamService};
|
||||||
BoxedServerService, InternalServiceFactory, ServerMessage, StreamService,
|
use crate::socket::{MioStream, MioTcpListener, StdSocketAddr, StdTcpListener, ToSocketAddrs};
|
||||||
};
|
|
||||||
use crate::socket::{MioTcpListener, StdSocketAddr, StdTcpListener, ToSocketAddrs};
|
|
||||||
use crate::LocalBoxFuture;
|
use crate::LocalBoxFuture;
|
||||||
use crate::Token;
|
use crate::Token;
|
||||||
|
|
||||||
|
@ -245,7 +243,7 @@ impl ServiceRuntime {
|
||||||
|
|
||||||
type BoxedNewService = Box<
|
type BoxedNewService = Box<
|
||||||
dyn actix::ServiceFactory<
|
dyn actix::ServiceFactory<
|
||||||
Request = (Option<CounterGuard>, ServerMessage),
|
Request = (Option<CounterGuard>, MioStream),
|
||||||
Response = (),
|
Response = (),
|
||||||
Error = (),
|
Error = (),
|
||||||
InitError = (),
|
InitError = (),
|
||||||
|
@ -267,7 +265,7 @@ where
|
||||||
T::Error: 'static,
|
T::Error: 'static,
|
||||||
T::InitError: fmt::Debug + 'static,
|
T::InitError: fmt::Debug + 'static,
|
||||||
{
|
{
|
||||||
type Request = (Option<CounterGuard>, ServerMessage);
|
type Request = (Option<CounterGuard>, MioStream);
|
||||||
type Response = ();
|
type Response = ();
|
||||||
type Error = ();
|
type Error = ();
|
||||||
type Config = ();
|
type Config = ();
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
//! General purpose TCP server.
|
//! General purpose TCP server.
|
||||||
|
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
mod accept;
|
mod accept;
|
||||||
mod builder;
|
mod builder;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use actix_service::{self as actix, Service, ServiceFactory as ActixServiceFactory};
|
use actix_service::{self as actix, Service, ServiceFactory as ActixServiceFactory};
|
||||||
use actix_utils::counter::CounterGuard;
|
use actix_utils::counter::CounterGuard;
|
||||||
|
@ -12,18 +11,6 @@ use crate::socket::{FromStream, MioStream};
|
||||||
use crate::LocalBoxFuture;
|
use crate::LocalBoxFuture;
|
||||||
use crate::Token;
|
use crate::Token;
|
||||||
|
|
||||||
/// Server message
|
|
||||||
pub(crate) enum ServerMessage {
|
|
||||||
/// New stream
|
|
||||||
Connect(MioStream),
|
|
||||||
|
|
||||||
/// Gracefully shutdown
|
|
||||||
Shutdown(Duration),
|
|
||||||
|
|
||||||
/// Force shutdown
|
|
||||||
ForceShutdown,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ServiceFactory<Stream: FromStream>: Send + Clone + 'static {
|
pub trait ServiceFactory<Stream: FromStream>: Send + Clone + 'static {
|
||||||
type Factory: actix::ServiceFactory<Config = (), Request = Stream>;
|
type Factory: actix::ServiceFactory<Config = (), Request = Stream>;
|
||||||
|
|
||||||
|
@ -40,7 +27,7 @@ pub(crate) trait InternalServiceFactory: Send {
|
||||||
|
|
||||||
pub(crate) type BoxedServerService = Box<
|
pub(crate) type BoxedServerService = Box<
|
||||||
dyn Service<
|
dyn Service<
|
||||||
Request = (Option<CounterGuard>, ServerMessage),
|
Request = (Option<CounterGuard>, MioStream),
|
||||||
Response = (),
|
Response = (),
|
||||||
Error = (),
|
Error = (),
|
||||||
Future = Ready<Result<(), ()>>,
|
Future = Ready<Result<(), ()>>,
|
||||||
|
@ -64,7 +51,7 @@ where
|
||||||
T::Error: 'static,
|
T::Error: 'static,
|
||||||
I: FromStream,
|
I: FromStream,
|
||||||
{
|
{
|
||||||
type Request = (Option<CounterGuard>, ServerMessage);
|
type Request = (Option<CounterGuard>, MioStream);
|
||||||
type Response = ();
|
type Response = ();
|
||||||
type Error = ();
|
type Error = ();
|
||||||
type Future = Ready<Result<(), ()>>;
|
type Future = Ready<Result<(), ()>>;
|
||||||
|
@ -73,21 +60,21 @@ where
|
||||||
self.service.poll_ready(ctx).map_err(|_| ())
|
self.service.poll_ready(ctx).map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self, (guard, req): (Option<CounterGuard>, ServerMessage)) -> Self::Future {
|
fn call(&mut self, (guard, req): (Option<CounterGuard>, MioStream)) -> Self::Future {
|
||||||
if let ServerMessage::Connect(stream) = req {
|
match FromStream::from_mio(stream) {
|
||||||
match FromStream::from_mio(stream) {
|
Ok(stream) => {
|
||||||
Ok(stream) => {
|
let f = self.service.call(stream);
|
||||||
let f = self.service.call(stream);
|
actix_rt::spawn(async move {
|
||||||
actix_rt::spawn(async move {
|
let _ = f.await;
|
||||||
let _ = f.await;
|
drop(guard);
|
||||||
drop(guard);
|
});
|
||||||
});
|
ready(Ok(()))
|
||||||
}
|
}
|
||||||
Err(e) => error!("Can not convert to an async tcp stream: {}", e),
|
Err(e) => {
|
||||||
};
|
error!("Can not convert to an async tcp stream: {}", e);
|
||||||
}
|
ready(Err(()))
|
||||||
|
}
|
||||||
ready(Ok(()))
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,20 +141,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InternalServiceFactory for Box<dyn InternalServiceFactory> {
|
|
||||||
fn name(&self, token: Token) -> &str {
|
|
||||||
self.as_ref().name(token)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clone_factory(&self) -> Box<dyn InternalServiceFactory> {
|
|
||||||
self.as_ref().clone_factory()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create(&self) -> LocalBoxFuture<'static, Result<Vec<(Token, BoxedServerService)>, ()>> {
|
|
||||||
self.as_ref().create()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<F, T, I> ServiceFactory<I> for F
|
impl<F, T, I> ServiceFactory<I> for F
|
||||||
where
|
where
|
||||||
F: Fn() -> T + Send + Clone + 'static,
|
F: Fn() -> T + Send + Clone + 'static,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use futures_util::stream::Stream;
|
||||||
use futures_util::TryFutureExt;
|
use futures_util::TryFutureExt;
|
||||||
use log::{error, info, trace};
|
use log::{error, info, trace};
|
||||||
|
|
||||||
use crate::service::{BoxedServerService, InternalServiceFactory, ServerMessage};
|
use crate::service::{BoxedServerService, InternalServiceFactory};
|
||||||
use crate::socket::{MioStream, SocketAddr};
|
use crate::socket::{MioStream, SocketAddr};
|
||||||
use crate::waker_queue::{WakerInterest, WakerQueue};
|
use crate::waker_queue::{WakerInterest, WakerQueue};
|
||||||
use crate::LocalBoxFuture;
|
use crate::LocalBoxFuture;
|
||||||
|
@ -233,21 +233,12 @@ impl Worker {
|
||||||
self.services.iter_mut().for_each(|srv| {
|
self.services.iter_mut().for_each(|srv| {
|
||||||
if srv.status == WorkerServiceStatus::Available {
|
if srv.status == WorkerServiceStatus::Available {
|
||||||
srv.status = WorkerServiceStatus::Stopped;
|
srv.status = WorkerServiceStatus::Stopped;
|
||||||
let fut = srv.service.call((None, ServerMessage::ForceShutdown));
|
|
||||||
spawn(async {
|
|
||||||
let _ = fut.await;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let timeout = self.shutdown_timeout;
|
|
||||||
self.services.iter_mut().for_each(move |srv| {
|
self.services.iter_mut().for_each(move |srv| {
|
||||||
if srv.status == WorkerServiceStatus::Available {
|
if srv.status == WorkerServiceStatus::Available {
|
||||||
srv.status = WorkerServiceStatus::Stopping;
|
srv.status = WorkerServiceStatus::Stopping;
|
||||||
let fut = srv.service.call((None, ServerMessage::Shutdown(timeout)));
|
|
||||||
spawn(async {
|
|
||||||
let _ = fut.await;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -443,7 +434,7 @@ impl Future for Worker {
|
||||||
let guard = self.conns.get();
|
let guard = self.conns.get();
|
||||||
let _ = self.services[msg.token.0]
|
let _ = self.services[msg.token.0]
|
||||||
.service
|
.service
|
||||||
.call((Some(guard), ServerMessage::Connect(msg.io)));
|
.call((Some(guard), msg.io));
|
||||||
}
|
}
|
||||||
Poll::Pending => return Poll::Pending,
|
Poll::Pending => return Poll::Pending,
|
||||||
Poll::Ready(None) => return Poll::Ready(()),
|
Poll::Ready(None) => return Poll::Ready(()),
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
//! See [`Service`](trait.Service.html) docs for information on this crate's foundational trait.
|
//! See [`Service`](trait.Service.html) docs for information on this crate's foundational trait.
|
||||||
|
|
||||||
#![deny(rust_2018_idioms, warnings)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
//! Various helpers for Actix applications to use during testing.
|
//! Various helpers for Actix applications to use during testing.
|
||||||
#![deny(rust_2018_idioms, warnings)]
|
|
||||||
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
#![allow(clippy::type_complexity, clippy::needless_doctest_main)]
|
#![allow(clippy::type_complexity, clippy::needless_doctest_main)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::{net, thread};
|
use std::{net, thread};
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
//! Thread pool for blocking operations
|
//! Thread pool for blocking operations
|
||||||
|
|
||||||
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
//! * `rustls` - TLS acceptor using the `rustls` crate.
|
//! * `rustls` - TLS acceptor using the `rustls` crate.
|
||||||
//! * `nativetls` - TLS acceptor using the `native-tls` crate.
|
//! * `nativetls` - TLS acceptor using the `native-tls` crate.
|
||||||
|
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
//! Actix tracing - support for tokio tracing with Actix services.
|
//! Actix tracing - support for tokio tracing with Actix services.
|
||||||
#![deny(rust_2018_idioms, warnings)]
|
|
||||||
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
//! Actix utils - various helper services
|
//! Actix utils - various helper services
|
||||||
|
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
pub mod condition;
|
pub mod condition;
|
||||||
pub mod counter;
|
pub mod counter;
|
||||||
|
|
|
@ -42,7 +42,7 @@ macro_rules! parse_single_value {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PathDeserializer<'de, T: ResourcePath + 'de> {
|
pub struct PathDeserializer<'de, T: ResourcePath> {
|
||||||
path: &'de Path<T>,
|
path: &'de Path<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
//! Resource path matching library.
|
//! Resource path matching library.
|
||||||
|
|
||||||
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
mod de;
|
mod de;
|
||||||
mod path;
|
mod path;
|
||||||
mod resource;
|
mod resource;
|
||||||
|
|
|
@ -158,7 +158,7 @@ impl<T: ResourcePath> Path<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return iterator to items in parameter container
|
/// Return iterator to items in parameter container
|
||||||
pub fn iter(&self) -> PathIter<T> {
|
pub fn iter(&self) -> PathIter<'_, T> {
|
||||||
PathIter {
|
PathIter {
|
||||||
idx: 0,
|
idx: 0,
|
||||||
params: self,
|
params: self,
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
//! A UTF-8 encoded read-only string using Bytes as storage.
|
//! A UTF-8 encoded read-only string using Bytes as storage.
|
||||||
|
|
||||||
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::{borrow, fmt, hash, ops, str};
|
use std::{borrow, fmt, hash, ops, str};
|
||||||
|
|
||||||
|
@ -156,13 +160,13 @@ macro_rules! array_impls {
|
||||||
array_impls!(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16);
|
array_impls!(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16);
|
||||||
|
|
||||||
impl fmt::Debug for ByteString {
|
impl fmt::Debug for ByteString {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
(**self).fmt(fmt)
|
(**self).fmt(fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ByteString {
|
impl fmt::Display for ByteString {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
(**self).fmt(fmt)
|
(**self).fmt(fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue