1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-14 14:30:32 +02:00

Compare commits

...

44 Commits

Author SHA1 Message Date
Yuki Okushi
61176f6410 Update rustls-related dependencies (#154) 2020-07-14 11:14:06 +01:00
Yuki Okushi
10b4c30a06 Use OR instead of deprecated / in license field (#155) 2020-07-14 11:11:30 +01:00
Yuki Okushi
7f550bcf0f threadpool: Bump up to 0.3.3 (#156) 2020-07-14 11:10:15 +01:00
Yuki Okushi
887f11f787 Merge pull request #153 from actix/tweak-actions
Tweak actions trigger events
2020-07-08 09:04:05 +09:00
Yuki Okushi
e2a6d352b0 Tweak actions trigger events 2020-07-08 08:38:24 +09:00
Yuki Okushi
f6c697a2dd Merge pull request #152 from paolobarbolini/pl-011
Update parking_lot to 0.11
2020-07-04 03:20:08 +09:00
Paolo Barbolini
5ecdfd684a Update parking_lot to 0.11 2020-07-03 17:37:10 +02:00
Yuki Okushi
7140c04c44 Merge pull request #149 from taiki-e/pin-project
Remove uses of pin_project::project attribute
2020-06-07 02:01:08 +09:00
Taiki Endo
9528df4486 Remove uses of pin_project::project attribute
pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: https://github.com/taiki-e/pin-project/issues/225
2020-06-06 06:42:45 +09:00
Pen Tree
755a8bb9d1 fix codec doc links (#148) 2020-06-02 18:05:39 +01:00
Yuki Okushi
f3cb6efc30 Merge pull request #146 from actix/cache-v2
Update `actions/cache` to v2
2020-05-28 04:59:34 +09:00
Yuki Okushi
87b857705c Update actions/cache to v2 2020-05-28 03:14:01 +09:00
Yuki Okushi
c897c5d3eb Merge pull request #145 from JohnTitor/new-threalpool
threadpool: Bump up to 0.3.2
2020-05-20 15:24:39 +09:00
Yuki Okushi
134e76b8b4 threadpool: Bump up to 0.3.2 2020-05-20 14:19:16 +09:00
Yuki Okushi
f3a401c23b Merge pull request #144 from JohnTitor/codecov-config
Add codecov config
2020-05-20 11:03:31 +09:00
Yuki Okushi
f7e8a912b3 Add codecov config 2020-05-19 14:45:39 +09:00
Yuki Okushi
11a1e11858 Merge pull request #143 from JohnTitor/new-testing
testing: Bump up to 1.0.1
2020-05-19 14:37:54 +09:00
Yuki Okushi
d0b27ee7e6 testing: Bump up to 1.0.1 2020-05-19 14:08:08 +09:00
Yuki Okushi
2d2b0591a2 Merge pull request #142 from JohnTitor/new-server
server: Bump up to 1.0.3
2020-05-19 13:58:39 +09:00
Yuki Okushi
abbc5f715f server: Bump up to 1.0.3 2020-05-19 10:23:17 +09:00
Yuki Okushi
140a6c76e3 Merge pull request #141 from actix/fix-ci
Only check compilation on mingw CI
2020-05-19 09:39:03 +09:00
Yuki Okushi
2395b28c5e Only check compilation on mingw CI
Disabled to run tests since somehow linking with OpenSSL is broken.
2020-05-19 09:11:27 +09:00
Yuki Okushi
aad4812ba6 Merge pull request #140 from JohnTitor/replace-net2
Replace deprecated `net2` crate with `socket2`
2020-05-19 08:58:40 +09:00
Yuki Okushi
ac6c78c476 testing: Replace net2 crate with socket2 2020-05-19 08:21:40 +09:00
Yuki Okushi
8218a098e8 server: Replace net2 crate with socket2 2020-05-19 08:17:44 +09:00
Yuki Okushi
49a6f525be Merge pull request #139 from JohnTitor/next-macros
macros: Bump up to 0.1.2
2020-05-19 07:50:46 +09:00
Yuki Okushi
f59ff82395 macros: Bump up to 0.1.2 2020-05-18 15:36:23 +09:00
Yuki Okushi
f7cc62564d Merge pull request #136 from JohnTitor/connect-alpha-3
actix-connect: Bump up to 2.0.0-alpha.3
2020-05-08 01:36:16 +09:00
Yuki Okushi
b125e2bdce actix-connect: Bump up to 2.0.0-alpha.3 2020-05-08 01:07:57 +09:00
Yuki Okushi
a5c185e80e Merge pull request #135 from actix/fix/unresolverd
correct spelling of ConnectError::Unresolved
2020-05-06 14:45:30 +09:00
Rob Ede
523cee0351 correct spelling of ConnectError::Unresolved 2020-05-03 23:14:22 +01:00
Yuki Okushi
343b3c09fc Merge pull request #134 from JohnTitor/new-rt
Bump up `actix-rt` to 1.1.1
2020-04-30 14:34:17 +09:00
Yuki Okushi
8a10580663 Bump up actix-rt to 1.1.1 2020-04-30 03:07:12 +09:00
Yuki Okushi
1b4a117063 Merge pull request #128 from Jonathas-Conceicao/topic/fix_memory_leak
actix-rt: Spawn future to cleanup pending JoinHandles
2020-04-30 02:58:13 +09:00
Yuki Okushi
700997fe48 Merge pull request #133 from actix/macro-compile-testing
add macro compile tests
2020-04-29 15:33:00 +09:00
Rob Ede
4c5568ed70 add trybuild compile tests 2020-04-26 20:11:16 +01:00
Yuki Okushi
7d0cfe1b4d Merge pull request #131 from danpintara/pull-1
actix-macros: Simplify test macros by using original signature
2020-04-23 02:33:52 +09:00
Daniel Pintara
e35c261c9f actix-macros: test: Simplify by using #sig instead of #name(#inputs) #ret 2020-04-22 00:13:32 +07:00
Yuki Okushi
115ef3fcb3 Merge pull request #130 from JohnTitor/dont-clone
Remove unnecessary clone usage
2020-04-20 08:37:10 +09:00
Yuki Okushi
c0482e2532 Remove unnecessary clone usage 2020-04-20 08:02:08 +09:00
Jonathas-Conceicao
6906f25e01 actix-rt: Set threshold size for arbiter's pending futures list
Signed-off-by: Jonathas-Conceicao <jadoliveira@inf.ufpel.edu.br>
2020-04-16 03:12:05 -03:00
Jonathas-Conceicao
06bca19524 actix-rt: Spawn future to cleanup pending JoinHandles
Signed-off-by: Jonathas-Conceicao <jadoliveira@inf.ufpel.edu.br>
2020-04-09 20:36:44 -03:00
Yuki Okushi
e9e2185296 Merge pull request #127 from rubdos/test-fixture-integration
Forward actix_rt::test arguments to test function.
2020-04-09 17:45:17 +09:00
Ruben De Smet
aae52a80ab Forward actix_rt::test arguments to test function.
Previously,

```rust
async fn foo(_a: u32) {}
```

would compile to

```rust
fn foo() {/* something */}
```

This patches changes this behaviour to

```rust
fn foo(_a: u32) {/* something */}
```

by simply forwarding the input arguments.

This allows any test fixture library (e.g. `rstest`, cfr.
https://github.com/la10736/rstest/issues/85) to integrate with
actix::test.
2020-04-08 16:48:10 +02:00
53 changed files with 342 additions and 171 deletions

View File

@@ -1,6 +1,12 @@
name: Benchmark (Linux) name: Benchmark (Linux)
on: [push, pull_request] on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
- '1.0'
jobs: jobs:
check_benchmark: check_benchmark:

View File

@@ -1,4 +1,6 @@
on: pull_request on:
pull_request:
types: [opened, synchronize, reopened]
name: Clippy Check name: Clippy Check
jobs: jobs:

View File

@@ -1,6 +1,12 @@
name: CI (Linux) name: CI (Linux)
on: [push, pull_request] on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
- '1.0'
jobs: jobs:
build_and_test: build_and_test:
@@ -29,18 +35,16 @@ jobs:
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: generate-lockfile command: generate-lockfile
- name: Cache cargo registry - name: Cache cargo dirs
uses: actions/cache@v1 uses: actions/cache@v2
with: with:
path: ~/.cargo/registry path:
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }} ~/.cargo/registry
- name: Cache cargo index ~/.cargo/git
uses: actions/cache@v1 ~/.cargo/bin
with: key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-trimmed-${{ hashFiles('**/Cargo.lock') }}
path: ~/.cargo/git
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build - name: Cache cargo build
uses: actions/cache@v1 uses: actions/cache@v2
with: with:
path: target path: target
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }} key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
@@ -61,7 +65,7 @@ jobs:
- name: Generate coverage file - name: Generate coverage file
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request') if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
run: | run: |
cargo install cargo-tarpaulin which cargo-tarpaulin || cargo install cargo-tarpaulin
cargo tarpaulin --out Xml --workspace --all-features cargo tarpaulin --out Xml --workspace --all-features
- name: Upload to Codecov - name: Upload to Codecov
@@ -72,5 +76,5 @@ jobs:
- name: Clear the cargo caches - name: Clear the cargo caches
run: | run: |
cargo install cargo-cache --no-default-features --features ci-autoclean which cargo-cache || cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache cargo-cache

View File

@@ -1,6 +1,12 @@
name: CI (macOS) name: CI (macOS)
on: [push, pull_request] on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
- '1.0'
jobs: jobs:
build_and_test: build_and_test:

View File

@@ -1,9 +1,12 @@
name: CI (Windows-mingw) name: CI (Windows-mingw)
on: [push, pull_request] on:
pull_request:
env: types: [opened, synchronize, reopened]
OPENSSL_DIR: d:\a\_temp\msys\msys64\usr push:
branches:
- master
- '1.0'
jobs: jobs:
build_and_test: build_and_test:
@@ -30,25 +33,13 @@ jobs:
- name: Install MSYS2 - name: Install MSYS2
uses: numworks/setup-msys2@v1 uses: numworks/setup-msys2@v1
- name: Install OpenSSL - name: Install packages
run: | run: |
msys2do pacman --noconfirm -S openssl-devel pkg-config msys2do pacman -Sy --noconfirm pacman
msys2do pacman --noconfirm -S base-devel pkg-config
- name: Copy and check libs
run: |
Copy-Item d:\a\_temp\msys\msys64\usr\lib\libssl.dll.a d:\a\_temp\msys\msys64\usr\lib\libssl.dll
Copy-Item d:\a\_temp\msys\msys64\usr\lib\libcrypto.dll.a d:\a\_temp\msys\msys64\usr\lib\libcrypto.dll
Get-ChildItem d:\a\_temp\msys\msys64\usr\lib
Get-ChildItem d:\a\_temp\msys\msys64\usr
- name: check build - name: check build
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: check command: check
args: --all --bins --examples --tests args: --all --bins --examples --tests
- name: tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --all-features --no-fail-fast -- --nocapture

View File

@@ -1,6 +1,12 @@
name: CI (Windows) name: CI (Windows)
on: [push, pull_request] on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
- '1.0'
env: env:
VCPKGRS_DYNAMIC: 1 VCPKGRS_DYNAMIC: 1

View File

@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-codec/" documentation = "https://docs.rs/actix-codec/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
workspace = ".." workspace = ".."
@@ -24,4 +24,4 @@ futures-sink = { version = "0.3.4", default-features = false }
tokio = { version = "0.2.4", default-features=false } tokio = { version = "0.2.4", default-features=false }
tokio-util = { version = "0.2.0", default-features=false, features=["codec"] } tokio-util = { version = "0.2.0", default-features=false, features=["codec"] }
log = "0.4" log = "0.4"
pin-project = "0.4.8" pin-project = "0.4.17"

View File

@@ -2,10 +2,12 @@
//! //!
//! Contains adapters to go from streams of bytes, [`AsyncRead`] and //! Contains adapters to go from streams of bytes, [`AsyncRead`] and
//! [`AsyncWrite`], to framed streams implementing [`Sink`] and [`Stream`]. //! [`AsyncWrite`], to framed streams implementing [`Sink`] and [`Stream`].
//! Framed streams are also known as [transports]. //! Framed streams are also known as `transports`.
//! //!
//! [`AsyncRead`]: # //! [`AsyncRead`]: AsyncRead
//! [`AsyncWrite`]: # //! [`AsyncWrite`]: AsyncWrite
//! [`Sink`]: futures_sink::Sink
//! [`Stream`]: futures_core::Stream
#![deny(rust_2018_idioms, warnings)] #![deny(rust_2018_idioms, warnings)]
mod bcodec; mod bcodec;

View File

@@ -1,5 +1,18 @@
# Changes # Changes
## [unreleased]
### Changed
* Update `rustls` dependency to 0.18
* Update `tokio-rustls` dependency to 0.14
## [2.0.0-alpha.3] - 2020-05-08
### Fixed
* Corrected spelling of `ConnectError::Unresolverd` to `ConnectError::Unresolved`
## [2.0.0-alpha.2] - 2020-03-08 ## [2.0.0-alpha.2] - 2020-03-08
### Changed ### Changed

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "actix-connect" name = "actix-connect"
version = "2.0.0-alpha.2" version = "2.0.0-alpha.3"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix connect - tcp connector service" description = "Actix connect - tcp connector service"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-connect/" documentation = "https://docs.rs/actix-connect/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[package.metadata.docs.rs] [package.metadata.docs.rs]
@@ -48,8 +48,8 @@ open-ssl = { version="0.10", package = "openssl", optional = true }
tokio-openssl = { version = "0.4.0", optional = true } tokio-openssl = { version = "0.4.0", optional = true }
# rustls # rustls
rust-tls = { version = "0.17.0", package = "rustls", optional = true } rust-tls = { version = "0.18.0", package = "rustls", optional = true }
tokio-rustls = { version = "0.13.0", optional = true } tokio-rustls = { version = "0.14.0", optional = true }
webpki = { version = "0.21", optional = true } webpki = { version = "0.21", optional = true }
[dev-dependencies] [dev-dependencies]

View File

@@ -88,7 +88,7 @@ impl<T: Address> Service for TcpConnector<T> {
Either::Left(TcpConnectorResponse::new(req, port, addr)) Either::Left(TcpConnectorResponse::new(req, port, addr))
} else { } else {
error!("TCP connector: got unresolved address"); error!("TCP connector: got unresolved address");
Either::Right(err(ConnectError::Unresolverd)) Either::Right(err(ConnectError::Unresolved))
} }
} }
} }

View File

@@ -18,7 +18,7 @@ pub enum ConnectError {
/// Unresolved host name /// Unresolved host name
#[display(fmt = "Connector received `Connect` method with unresolved host")] #[display(fmt = "Connector received `Connect` method with unresolved host")]
Unresolverd, Unresolved,
/// Connection io error /// Connection io error
#[display(fmt = "{}", _0)] #[display(fmt = "{}", _0)]

View File

@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-ioframe/" documentation = "https://docs.rs/actix-ioframe/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[lib] [lib]
@@ -24,7 +24,7 @@ bytes = "0.5.3"
either = "1.5.3" either = "1.5.3"
futures-sink = { version = "0.3.4", default-features = false } futures-sink = { version = "0.3.4", default-features = false }
futures-core = { version = "0.3.4", default-features = false } futures-core = { version = "0.3.4", default-features = false }
pin-project = "0.4.6" pin-project = "0.4.17"
log = "0.4" log = "0.4"
[dev-dependencies] [dev-dependencies]

View File

@@ -8,7 +8,6 @@ use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder, Framed};
use actix_service::{IntoService, IntoServiceFactory, Service, ServiceFactory}; use actix_service::{IntoService, IntoServiceFactory, Service, ServiceFactory};
use either::Either; use either::Either;
use futures_core::{ready, stream::Stream}; use futures_core::{ready, stream::Stream};
use pin_project::project;
use crate::connect::{Connect, ConnectResult}; use crate::connect::{Connect, ConnectResult};
use crate::dispatcher::Dispatcher; use crate::dispatcher::Dispatcher;
@@ -336,7 +335,7 @@ where
} }
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = FramedServiceImplResponseInnerProj)]
enum FramedServiceImplResponseInner<St, Io, Codec, Out, C, T> enum FramedServiceImplResponseInner<St, Io, Codec, Out, C, T>
where where
C: Service<Request = Connect<Io, Codec>, Response = ConnectResult<Io, St, Codec, Out>>, C: Service<Request = Connect<Io, Codec>, Response = ConnectResult<Io, St, Codec, Out>>,
@@ -378,7 +377,6 @@ where
<Codec as Encoder>::Error: std::fmt::Debug, <Codec as Encoder>::Error: std::fmt::Debug,
Out: Stream<Item = <Codec as Encoder>::Item> + Unpin, Out: Stream<Item = <Codec as Encoder>::Item> + Unpin,
{ {
#[project]
fn poll( fn poll(
self: Pin<&mut Self>, self: Pin<&mut Self>,
cx: &mut Context<'_>, cx: &mut Context<'_>,
@@ -386,9 +384,8 @@ where
FramedServiceImplResponseInner<St, Io, Codec, Out, C, T>, FramedServiceImplResponseInner<St, Io, Codec, Out, C, T>,
Poll<Result<(), ServiceError<C::Error, Codec>>>, Poll<Result<(), ServiceError<C::Error, Codec>>>,
> { > {
#[project]
match self.project() { match self.project() {
FramedServiceImplResponseInner::Connect(fut, handler) => match fut.poll(cx) { FramedServiceImplResponseInnerProj::Connect(fut, handler) => match fut.poll(cx) {
Poll::Ready(Ok(res)) => Either::Left(FramedServiceImplResponseInner::Handler( Poll::Ready(Ok(res)) => Either::Left(FramedServiceImplResponseInner::Handler(
handler.new_service(res.state), handler.new_service(res.state),
Some(res.framed), Some(res.framed),
@@ -397,7 +394,7 @@ where
Poll::Pending => Either::Right(Poll::Pending), Poll::Pending => Either::Right(Poll::Pending),
Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))), Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))),
}, },
FramedServiceImplResponseInner::Handler(fut, framed, out) => { FramedServiceImplResponseInnerProj::Handler(fut, framed, out) => {
match fut.poll(cx) { match fut.poll(cx) {
Poll::Ready(Ok(handler)) => { Poll::Ready(Ok(handler)) => {
Either::Left(FramedServiceImplResponseInner::Dispatcher( Either::Left(FramedServiceImplResponseInner::Dispatcher(
@@ -408,7 +405,7 @@ where
Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))), Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))),
} }
} }
FramedServiceImplResponseInner::Dispatcher(fut) => { FramedServiceImplResponseInnerProj::Dispatcher(fut) => {
Either::Right(fut.poll(cx)) Either::Right(fut.poll(cx))
} }
} }

1
actix-macros/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/wip

9
actix-macros/CHANGES.md Normal file
View File

@@ -0,0 +1,9 @@
# CHANGES
## 0.1.2 - 2020-05-18
### Changed
* Forward actix_rt::test arguments to test function [#127]
[#127]: https://github.com/actix/actix-net/pull/127

View File

@@ -1,14 +1,13 @@
[package] [package]
name = "actix-macros" name = "actix-macros"
version = "0.1.1" version = "0.1.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix runtime macros" description = "Actix runtime macros"
repository = "https://github.com/actix/actix-net" repository = "https://github.com/actix/actix-net"
documentation = "https://docs.rs/actix-macros/" documentation = "https://docs.rs/actix-macros/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
workspace = ".."
[lib] [lib]
proc-macro = true proc-macro = true
@@ -18,4 +17,7 @@ quote = "1.0.3"
syn = { version = "^1", features = ["full"] } syn = { version = "^1", features = ["full"] }
[dev-dependencies] [dev-dependencies]
actix-rt = { version = "1.0.0" } actix-rt = "1.0"
futures-util = { version = "0.3", default-features = false }
trybuild = "1"

View File

@@ -55,12 +55,11 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
/// ``` /// ```
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn test(_: TokenStream, item: TokenStream) -> TokenStream { pub fn test(_: TokenStream, item: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(item as syn::ItemFn); let mut input = syn::parse_macro_input!(item as syn::ItemFn);
let ret = &input.sig.output;
let name = &input.sig.ident;
let body = &input.block;
let attrs = &input.attrs; let attrs = &input.attrs;
let vis = &input.vis;
let sig = &mut input.sig;
let body = &input.block;
let mut has_test_attr = false; let mut has_test_attr = false;
for attr in attrs { for attr in attrs {
@@ -69,7 +68,7 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream {
} }
} }
if input.sig.asyncness.is_none() { if sig.asyncness.is_none() {
return syn::Error::new_spanned( return syn::Error::new_spanned(
input.sig.fn_token, input.sig.fn_token,
format!("only async fn is supported, {}", input.sig.ident), format!("only async fn is supported, {}", input.sig.ident),
@@ -78,10 +77,12 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream {
.into(); .into();
} }
sig.asyncness = None;
let result = if has_test_attr { let result = if has_test_attr {
quote! { quote! {
#(#attrs)* #(#attrs)*
fn #name() #ret { #vis #sig {
actix_rt::System::new("test") actix_rt::System::new("test")
.block_on(async { #body }) .block_on(async { #body })
} }
@@ -90,7 +91,7 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream {
quote! { quote! {
#[test] #[test]
#(#attrs)* #(#attrs)*
fn #name() #ret { #vis #sig {
actix_rt::System::new("test") actix_rt::System::new("test")
.block_on(async { #body }) .block_on(async { #body })
} }

View File

@@ -0,0 +1,9 @@
#[test]
fn compile_macros() {
let t = trybuild::TestCases::new();
t.pass("tests/trybuild/main-01-basic.rs");
t.compile_fail("tests/trybuild/main-02-only-async.rs");
t.pass("tests/trybuild/test-01-basic.rs");
t.pass("tests/trybuild/test-02-keep-attrs.rs");
}

View File

@@ -0,0 +1,4 @@
#[actix_rt::main]
async fn main() {
println!("Hello world");
}

View File

@@ -0,0 +1,4 @@
#[actix_rt::main]
fn main() {
futures_util::future::ready(()).await
}

View File

@@ -0,0 +1,14 @@
error: only async fn is supported
--> $DIR/main-02-only-async.rs:2:1
|
2 | fn main() {
| ^^
error[E0601]: `main` function not found in crate `$CRATE`
--> $DIR/main-02-only-async.rs:1:1
|
1 | / #[actix_rt::main]
2 | | fn main() {
3 | | futures_util::future::ready(()).await
4 | | }
| |_^ consider adding a `main` function to `$DIR/tests/trybuild/main-02-only-async.rs`

View File

@@ -0,0 +1,6 @@
#[actix_rt::test]
async fn my_test() {
assert!(true);
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[actix_rt::test]
#[should_panic]
async fn my_test() {
todo!()
}
fn main() {}

View File

@@ -1,7 +1,17 @@
# Changes # Changes
## [1.1.1] - 2020-04-30
### Fixed
* Fix memory leak due to [#94] (see [#129] for more detail)
[#129]: https://github.com/actix/actix-net/issues/129
## [1.1.0] - 2020-04-08 ## [1.1.0] - 2020-04-08
**This version has been yanked.**
### Added ### Added
* Expose `System::is_set` to check if current system has ben started [#99] * Expose `System::is_set` to check if current system has ben started [#99]

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "actix-rt" name = "actix-rt"
version = "1.1.0" version = "1.1.1"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix runtime" description = "Actix runtime"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-rt/" documentation = "https://docs.rs/actix-rt/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[lib] [lib]
@@ -21,4 +21,5 @@ actix-threadpool = "0.3"
futures-channel = { version = "0.3.4", default-features = false } futures-channel = { version = "0.3.4", default-features = false }
futures-util = { version = "0.3.4", default-features = false, features = ["alloc"] } futures-util = { version = "0.3.4", default-features = false, features = ["alloc"] }
copyless = "0.1.4" copyless = "0.1.4"
smallvec = "1"
tokio = { version = "0.2.6", default-features = false, features = ["rt-core", "rt-util", "io-driver", "tcp", "uds", "udp", "time", "signal", "stream"] } tokio = { version = "0.2.6", default-features = false, features = ["rt-core", "rt-util", "io-driver", "tcp", "uds", "udp", "time", "signal", "stream"] }

View File

@@ -18,13 +18,14 @@ use crate::system::System;
use copyless::BoxHelper; use copyless::BoxHelper;
use smallvec::SmallVec;
pub use tokio::task::JoinHandle; pub use tokio::task::JoinHandle;
thread_local!( thread_local!(
static ADDR: RefCell<Option<Arbiter>> = RefCell::new(None); static ADDR: RefCell<Option<Arbiter>> = RefCell::new(None);
static RUNNING: Cell<bool> = Cell::new(false); static RUNNING: Cell<bool> = Cell::new(false);
static Q: RefCell<Vec<Pin<Box<dyn Future<Output = ()>>>>> = RefCell::new(Vec::new()); static Q: RefCell<Vec<Pin<Box<dyn Future<Output = ()>>>>> = RefCell::new(Vec::new());
static PENDING: RefCell<Vec<JoinHandle<()>>> = RefCell::new(Vec::new()); static PENDING: RefCell<SmallVec<[JoinHandle<()>; 8]>> = RefCell::new(SmallVec::new());
static STORAGE: RefCell<HashMap<TypeId, Box<dyn Any>>> = RefCell::new(HashMap::new()); static STORAGE: RefCell<HashMap<TypeId, Box<dyn Any>>> = RefCell::new(HashMap::new());
); );
@@ -181,9 +182,15 @@ impl Arbiter {
RUNNING.with(move |cell| { RUNNING.with(move |cell| {
if cell.get() { if cell.get() {
// Spawn the future on running executor // Spawn the future on running executor
PENDING.with(move |cell| { let len = PENDING.with(move |cell| {
cell.borrow_mut().push(tokio::task::spawn_local(future)); let mut p = cell.borrow_mut();
}) p.push(tokio::task::spawn_local(future));
p.len()
});
if len > 7 {
// Before reaching the inline size
tokio::task::spawn_local(CleanupPending);
}
} else { } else {
// Box the future and push it to the queue, this results in double boxing // Box the future and push it to the queue, this results in double boxing
// because the executor boxes the future again, but works for now // because the executor boxes the future again, but works for now
@@ -311,12 +318,36 @@ impl Arbiter {
/// have completed. /// have completed.
pub fn local_join() -> impl Future<Output = ()> { pub fn local_join() -> impl Future<Output = ()> {
PENDING.with(move |cell| { PENDING.with(move |cell| {
let current = cell.replace(Vec::new()); let current = cell.replace(SmallVec::new());
future::join_all(current).map(|_| ()) future::join_all(current).map(|_| ())
}) })
} }
} }
/// Future used for cleaning-up already finished `JoinHandle`s
/// from the `PENDING` list so the vector doesn't grow indefinitely
struct CleanupPending;
impl Future for CleanupPending {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
PENDING.with(move |cell| {
let mut pending = cell.borrow_mut();
let mut i = 0;
while i != pending.len() {
if let Poll::Ready(_) = Pin::new(&mut pending[i]).poll(cx) {
pending.remove(i);
} else {
i += 1;
}
}
});
Poll::Ready(())
}
}
struct ArbiterController { struct ArbiterController {
stop: Option<Sender<i32>>, stop: Option<Sender<i32>>,
rx: UnboundedReceiver<ArbiterCommand>, rx: UnboundedReceiver<ArbiterCommand>,
@@ -350,9 +381,15 @@ impl Future for ArbiterController {
return Poll::Ready(()); return Poll::Ready(());
} }
ArbiterCommand::Execute(fut) => { ArbiterCommand::Execute(fut) => {
PENDING.with(move |cell| { let len = PENDING.with(move |cell| {
cell.borrow_mut().push(tokio::task::spawn_local(fut)); let mut p = cell.borrow_mut();
p.push(tokio::task::spawn_local(fut));
p.len()
}); });
if len > 7 {
// Before reaching the inline size
tokio::task::spawn_local(CleanupPending);
}
} }
ArbiterCommand::ExecuteFn(f) => { ArbiterCommand::ExecuteFn(f) => {
f.call_box(); f.call_box();

View File

@@ -1,5 +1,13 @@
# Changes # Changes
## [1.0.3] - 2020-05-19
### Changed
* Replace deprecated `net2` crate with `socket2` [#140]
[#140]: https://github.com/actix/actix-net/pull/140
## [1.0.2] - 2020-02-26 ## [1.0.2] - 2020-02-26
### Fixed ### Fixed

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "actix-server" name = "actix-server"
version = "1.0.2" version = "1.0.3"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix server - General purpose tcp server" description = "Actix server - General purpose tcp server"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@@ -8,8 +8,8 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-server/" documentation = "https://docs.rs/actix-server/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"] exclude = [".gitignore", ".cargo/config"]
edition = "2018" edition = "2018"
workspace = ".." workspace = ".."
@@ -29,7 +29,7 @@ actix-utils = "1.0.4"
log = "0.4" log = "0.4"
num_cpus = "1.11" num_cpus = "1.11"
mio = "0.6.19" mio = "0.6.19"
net2 = "0.2" socket2 = "0.3"
futures-channel = { version = "0.3.4", default-features = false } futures-channel = { version = "0.3.4", default-features = false }
futures-util = { version = "0.3.4", default-features = false, features = ["sink"] } futures-util = { version = "0.3.4", default-features = false, features = ["sink"] }
slab = "0.4" slab = "0.4"

View File

@@ -10,9 +10,9 @@ use futures_channel::mpsc::{unbounded, UnboundedReceiver};
use futures_channel::oneshot; use futures_channel::oneshot;
use futures_util::future::ready; use futures_util::future::ready;
use futures_util::stream::FuturesUnordered; use futures_util::stream::FuturesUnordered;
use futures_util::{ready, future::Future, FutureExt, stream::Stream, StreamExt}; use futures_util::{future::Future, ready, stream::Stream, FutureExt, StreamExt};
use log::{error, info}; use log::{error, info};
use net2::TcpBuilder; use socket2::{Domain, Protocol, Socket, Type};
use crate::accept::{AcceptLoop, AcceptNotify, Command}; use crate::accept::{AcceptLoop, AcceptNotify, Command};
use crate::config::{ConfiguredService, ServiceConfig}; use crate::config::{ConfiguredService, ServiceConfig};
@@ -381,7 +381,7 @@ impl ServerBuilder {
.await; .await;
System::current().stop(); System::current().stop();
} }
.boxed(), .boxed(),
); );
} }
ready(()) ready(())
@@ -487,11 +487,13 @@ pub(super) fn bind_addr<S: net::ToSocketAddrs>(
} }
fn create_tcp_listener(addr: net::SocketAddr, backlog: i32) -> io::Result<net::TcpListener> { fn create_tcp_listener(addr: net::SocketAddr, backlog: i32) -> io::Result<net::TcpListener> {
let builder = match addr { let domain = match addr {
net::SocketAddr::V4(_) => TcpBuilder::new_v4()?, net::SocketAddr::V4(_) => Domain::ipv4(),
net::SocketAddr::V6(_) => TcpBuilder::new_v6()?, net::SocketAddr::V6(_) => Domain::ipv6(),
}; };
builder.reuse_address(true)?; let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
builder.bind(addr)?; socket.set_reuse_address(true)?;
Ok(builder.listen(backlog)?) socket.bind(&addr.into())?;
socket.listen(backlog)?;
Ok(socket.into_tcp_listener())
} }

View File

@@ -218,7 +218,7 @@ impl ServiceRuntime {
// let name = name.to_owned(); // let name = name.to_owned();
if let Some(token) = self.names.get(name) { if let Some(token) = self.names.get(name) {
self.services.insert( self.services.insert(
token.clone(), *token,
Box::new(ServiceFactory { Box::new(ServiceFactory {
inner: service.into_factory(), inner: service.into_factory(),
}), }),

View File

@@ -10,7 +10,7 @@ use actix_utils::counter::Counter;
use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender}; use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
use futures_channel::oneshot; use futures_channel::oneshot;
use futures_util::future::{join_all, LocalBoxFuture, MapOk}; use futures_util::future::{join_all, LocalBoxFuture, MapOk};
use futures_util::{future::Future, FutureExt, stream::Stream, TryFutureExt}; use futures_util::{future::Future, stream::Stream, FutureExt, TryFutureExt};
use log::{error, info, trace}; use log::{error, info, trace};
use crate::accept::AcceptNotify; use crate::accept::AcceptNotify;

View File

@@ -5,14 +5,14 @@ use std::{net, thread, time};
use actix_server::Server; use actix_server::Server;
use actix_service::fn_service; use actix_service::fn_service;
use futures_util::future::{lazy, ok}; use futures_util::future::{lazy, ok};
use net2::TcpBuilder; use socket2::{Domain, Protocol, Socket, Type};
fn unused_addr() -> net::SocketAddr { fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap(); let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = TcpBuilder::new_v4().unwrap(); let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
socket.bind(&addr).unwrap(); socket.bind(&addr.into()).unwrap();
socket.reuse_address(true).unwrap(); socket.set_reuse_address(true).unwrap();
let tcp = socket.to_tcp_listener().unwrap(); let tcp = socket.into_tcp_listener();
tcp.local_addr().unwrap() tcp.local_addr().unwrap()
} }
@@ -83,12 +83,10 @@ fn test_start() {
.backlog(100) .backlog(100)
.disable_signals() .disable_signals()
.bind("test", addr, move || { .bind("test", addr, move || {
fn_service(|io: TcpStream| { fn_service(|io: TcpStream| async move {
async move { let mut f = Framed::new(io, BytesCodec);
let mut f = Framed::new(io, BytesCodec); f.send(Bytes::from_static(b"test")).await.unwrap();
f.send(Bytes::from_static(b"test")).await.unwrap(); Ok::<_, ()>(())
Ok::<_, ()>(())
}
}) })
}) })
.unwrap() .unwrap()

View File

@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-service/" documentation = "https://docs.rs/actix-service/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[lib] [lib]
@@ -17,7 +17,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
futures-util = "0.3.1" futures-util = "0.3.1"
pin-project = "0.4.6" pin-project = "0.4.17"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0" actix-rt = "1.0.0"

View File

@@ -81,7 +81,7 @@ where
state: State<A, B>, state: State<A, B>,
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = StateProj)]
enum State<A, B> enum State<A, B>
where where
A: Service, A: Service,
@@ -99,13 +99,11 @@ where
{ {
type Output = Result<B::Response, A::Error>; type Output = Result<B::Response, A::Error>;
#[pin_project::project]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
#[project]
match this.state.as_mut().project() { match this.state.as_mut().project() {
State::A(fut, b) => match fut.poll(cx)? { StateProj::A(fut, b) => match fut.poll(cx)? {
Poll::Ready(res) => { Poll::Ready(res) => {
let b = b.take().unwrap(); let b = b.take().unwrap();
this.state.set(State::Empty); // drop fut A this.state.set(State::Empty); // drop fut A
@@ -115,11 +113,11 @@ where
} }
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}, },
State::B(fut) => fut.poll(cx).map(|r| { StateProj::B(fut) => fut.poll(cx).map(|r| {
this.state.set(State::Empty); this.state.set(State::Empty);
r r
}), }),
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"), StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
} }
} }
} }
@@ -179,7 +177,7 @@ where
state: StateRC<A, B>, state: StateRC<A, B>,
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = StateRCProj)]
enum StateRC<A, B> enum StateRC<A, B>
where where
A: Service, A: Service,
@@ -196,14 +194,12 @@ where
B: Service<Request = A::Response, Error = A::Error>, B: Service<Request = A::Response, Error = A::Error>,
{ {
type Output = Result<B::Response, A::Error>; type Output = Result<B::Response, A::Error>;
#[pin_project::project]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
#[project]
match this.state.as_mut().project() { match this.state.as_mut().project() {
StateRC::A(fut, b) => match fut.poll(cx)? { StateRCProj::A(fut, b) => match fut.poll(cx)? {
Poll::Ready(res) => { Poll::Ready(res) => {
let b = b.take().unwrap(); let b = b.take().unwrap();
this.state.set(StateRC::Empty); // drop fut A this.state.set(StateRC::Empty); // drop fut A
@@ -213,11 +209,11 @@ where
} }
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}, },
StateRC::B(fut) => fut.poll(cx).map(|r| { StateRCProj::B(fut) => fut.poll(cx).map(|r| {
this.state.set(StateRC::Empty); this.state.set(StateRC::Empty);
r r
}), }),
StateRC::Empty => panic!("future must not be polled after it returned `Poll::Ready`"), StateRCProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
} }
} }
} }

View File

@@ -66,7 +66,7 @@ where
state: State<A, B>, state: State<A, B>,
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = StateProj)]
enum State<A, B> enum State<A, B>
where where
A: Service, A: Service,
@@ -84,13 +84,11 @@ where
{ {
type Output = Result<B::Response, A::Error>; type Output = Result<B::Response, A::Error>;
#[pin_project::project]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
#[project]
match this.state.as_mut().project() { match this.state.as_mut().project() {
State::A(fut, b) => match fut.poll(cx)? { StateProj::A(fut, b) => match fut.poll(cx)? {
Poll::Ready(res) => { Poll::Ready(res) => {
let mut b = b.take().unwrap(); let mut b = b.take().unwrap();
this.state.set(State::Empty); // drop fut A this.state.set(State::Empty); // drop fut A
@@ -100,11 +98,11 @@ where
} }
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}, },
State::B(fut) => fut.poll(cx).map(|r| { StateProj::B(fut) => fut.poll(cx).map(|r| {
this.state.set(State::Empty); this.state.set(State::Empty);
r r
}), }),
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"), StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
} }
} }
} }

View File

@@ -98,7 +98,7 @@ where
state: State<A, B, F, Fut, Res, Err>, state: State<A, B, F, Fut, Res, Err>,
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = StateProj)]
enum State<A, B, F, Fut, Res, Err> enum State<A, B, F, Fut, Res, Err>
where where
A: Service, A: Service,
@@ -123,13 +123,11 @@ where
{ {
type Output = Result<Res, Err>; type Output = Result<Res, Err>;
#[pin_project::project]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
#[project]
match this.state.as_mut().project() { match this.state.as_mut().project() {
State::A(fut, b) => match fut.poll(cx)? { StateProj::A(fut, b) => match fut.poll(cx)? {
Poll::Ready(res) => { Poll::Ready(res) => {
let mut b = b.take().unwrap(); let mut b = b.take().unwrap();
this.state.set(State::Empty); this.state.set(State::Empty);
@@ -140,11 +138,11 @@ where
} }
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}, },
State::B(fut) => fut.poll(cx).map(|r| { StateProj::B(fut) => fut.poll(cx).map(|r| {
this.state.set(State::Empty); this.state.set(State::Empty);
r r
}), }),
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"), StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
} }
} }
} }

View File

@@ -177,7 +177,7 @@ where
state: State<T, R, S>, state: State<T, R, S>,
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = StateProj)]
enum State<T, R, S> enum State<T, R, S>
where where
T: ServiceFactory<Config = ()>, T: ServiceFactory<Config = ()>,
@@ -200,20 +200,18 @@ where
{ {
type Output = Result<S, T::InitError>; type Output = Result<S, T::InitError>;
#[pin_project::project]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
#[project]
match this.state.as_mut().project() { match this.state.as_mut().project() {
State::A(fut) => match fut.poll(cx)? { StateProj::A(fut) => match fut.poll(cx)? {
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
Poll::Ready(srv) => { Poll::Ready(srv) => {
this.state.set(State::B(srv)); this.state.set(State::B(srv));
self.poll(cx) self.poll(cx)
} }
}, },
State::B(srv) => match srv.poll_ready(cx)? { StateProj::B(srv) => match srv.poll_ready(cx)? {
Poll::Ready(_) => { Poll::Ready(_) => {
let fut = (this.store.get_mut().1)(this.cfg.take().unwrap(), srv); let fut = (this.store.get_mut().1)(this.cfg.take().unwrap(), srv);
this.state.set(State::C(fut)); this.state.set(State::C(fut));
@@ -221,7 +219,7 @@ where
} }
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}, },
State::C(fut) => fut.poll(cx), StateProj::C(fut) => fut.poll(cx),
} }
} }
} }

View File

@@ -66,7 +66,7 @@ where
state: State<A, B>, state: State<A, B>,
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = StateProj)]
enum State<A, B> enum State<A, B>
where where
A: Service, A: Service,
@@ -84,13 +84,11 @@ where
{ {
type Output = Result<B::Response, B::Error>; type Output = Result<B::Response, B::Error>;
#[pin_project::project]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
#[project]
match this.state.as_mut().project() { match this.state.as_mut().project() {
State::A(fut, b) => match fut.poll(cx) { StateProj::A(fut, b) => match fut.poll(cx) {
Poll::Ready(res) => { Poll::Ready(res) => {
let mut b = b.take().unwrap(); let mut b = b.take().unwrap();
this.state.set(State::Empty); // drop fut A this.state.set(State::Empty); // drop fut A
@@ -100,11 +98,11 @@ where
} }
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}, },
State::B(fut) => fut.poll(cx).map(|r| { StateProj::B(fut) => fut.poll(cx).map(|r| {
this.state.set(State::Empty); this.state.set(State::Empty);
r r
}), }),
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"), StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
} }
} }
} }

View File

@@ -211,7 +211,7 @@ where
state: ApplyTransformFutureState<T, S>, state: ApplyTransformFutureState<T, S>,
} }
#[pin_project::pin_project] #[pin_project::pin_project(project = ApplyTransformFutureStateProj)]
pub enum ApplyTransformFutureState<T, S> pub enum ApplyTransformFutureState<T, S>
where where
S: ServiceFactory, S: ServiceFactory,
@@ -228,13 +228,11 @@ where
{ {
type Output = Result<T::Transform, T::InitError>; type Output = Result<T::Transform, T::InitError>;
#[pin_project::project]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
#[project]
match this.state.as_mut().project() { match this.state.as_mut().project() {
ApplyTransformFutureState::A(fut) => match fut.poll(cx)? { ApplyTransformFutureStateProj::A(fut) => match fut.poll(cx)? {
Poll::Ready(srv) => { Poll::Ready(srv) => {
let fut = this.store.0.new_transform(srv); let fut = this.store.0.new_transform(srv);
this.state.set(ApplyTransformFutureState::B(fut)); this.state.set(ApplyTransformFutureState::B(fut));
@@ -242,7 +240,7 @@ where
} }
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}, },
ApplyTransformFutureState::B(fut) => fut.poll(cx), ApplyTransformFutureStateProj::B(fut) => fut.poll(cx),
} }
} }
} }

View File

@@ -1,5 +1,11 @@
# Changes # Changes
## [1.0.1] - 2020-05-19
* Replace deprecated `net2` crate with `socket2`
* Remove unused `futures` dependency
## [1.0.0] - 2019-12-11 ## [1.0.0] - 2019-12-11
* Update actix-server to 1.0.0 * Update actix-server to 1.0.0

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "actix-testing" name = "actix-testing"
version = "1.0.0" version = "1.0.1"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix testing utils" description = "Actix testing utils"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@@ -8,9 +8,10 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-testing/" documentation = "https://docs.rs/actix-testing/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
workspace = ".." workspace = ".."
readme = "README.md"
[lib] [lib]
name = "actix_testing" name = "actix_testing"
@@ -23,4 +24,4 @@ actix-server = "1.0.0"
actix-service = "1.0.0" actix-service = "1.0.0"
log = "0.4" log = "0.4"
net2 = "0.2" socket2 = "0.3"

View File

@@ -7,7 +7,7 @@ use std::{net, thread};
use actix_rt::{net::TcpStream, System}; use actix_rt::{net::TcpStream, System};
use actix_server::{Server, ServerBuilder, ServiceFactory}; use actix_server::{Server, ServerBuilder, ServiceFactory};
use net2::TcpBuilder; use socket2::{Domain, Protocol, Socket, Type};
#[cfg(not(test))] // Work around for rust-lang/rust#62127 #[cfg(not(test))] // Work around for rust-lang/rust#62127
pub use actix_macros::test; pub use actix_macros::test;
@@ -110,10 +110,11 @@ impl TestServer {
/// Get firat available unused local address /// Get firat available unused local address
pub fn unused_addr() -> net::SocketAddr { pub fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap(); let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = TcpBuilder::new_v4().unwrap(); let socket =
socket.bind(&addr).unwrap(); Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
socket.reuse_address(true).unwrap(); socket.bind(&addr.into()).unwrap();
let tcp = socket.to_tcp_listener().unwrap(); socket.set_reuse_address(true).unwrap();
let tcp = socket.into_tcp_listener();
tcp.local_addr().unwrap() tcp.local_addr().unwrap()
} }
} }

View File

@@ -1,10 +1,24 @@
# Changes # Changes
## [0.3.3] - 2020-07-14
### Changed
* Update parking_lot to 0.11
## [0.3.2] - 2020-05-20
## Added
* Implement `std::error::Error` for `BlockingError` [#120]
[#120]: https://github.com/actix/actix-net/pull/120
## [0.3.1] - 2019-12-12 ## [0.3.1] - 2019-12-12
### Changed ### Changed
* Use parking_lot 0.10 * Update parking_lot to 0.10
## [0.3.0] - 2019-12-02 ## [0.3.0] - 2019-12-02

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "actix-threadpool" name = "actix-threadpool"
version = "0.3.1" version = "0.3.3"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix thread pool for sync code" description = "Actix thread pool for sync code"
keywords = ["actix", "network", "framework", "async", "futures"] keywords = ["actix", "network", "framework", "async", "futures"]
@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-threadpool/" documentation = "https://docs.rs/actix-threadpool/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"] exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
edition = "2018" edition = "2018"
workspace = ".." workspace = ".."
@@ -20,7 +20,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
derive_more = "0.99.2" derive_more = "0.99.2"
futures-channel = "0.3.1" futures-channel = "0.3.1"
parking_lot = "0.10" parking_lot = "0.11"
lazy_static = "1.3" lazy_static = "1.3"
log = "0.4" log = "0.4"
num_cpus = "1.10" num_cpus = "1.10"

View File

@@ -1,5 +1,13 @@
# Changes # Changes
## [unreleased]
### Changed
* Update `rustls` dependency to 0.18
* Update `tokio-rustls` dependency to 0.14
* Update `webpki-roots` dependency to 0.20
## [2.0.0-alpha.1] - 2020-03-03 ## [2.0.0-alpha.1] - 2020-03-03
### Changed ### Changed

View File

@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-tls/" documentation = "https://docs.rs/actix-tls/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
workspace = ".." workspace = ".."
@@ -46,10 +46,10 @@ open-ssl = { version="0.10", package = "openssl", optional = true }
tokio-openssl = { version = "0.4.0", optional = true } tokio-openssl = { version = "0.4.0", optional = true }
# rustls # rustls
rust-tls = { version = "0.17.0", package = "rustls", optional = true } rust-tls = { version = "0.18.0", package = "rustls", optional = true }
webpki = { version = "0.21", optional = true } webpki = { version = "0.21", optional = true }
webpki-roots = { version = "0.19", optional = true } webpki-roots = { version = "0.20", optional = true }
tokio-rustls = { version = "0.13.0", optional = true } tokio-rustls = { version = "0.14.0", optional = true }
# native-tls # native-tls
native-tls = { version="0.2", optional = true } native-tls = { version="0.2", optional = true }

View File

@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-tracing/" documentation = "https://docs.rs/actix-tracing/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[lib] [lib]

View File

@@ -8,7 +8,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-utils/" documentation = "https://docs.rs/actix-utils/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[lib] [lib]
@@ -25,6 +25,6 @@ either = "1.5.3"
futures-channel = { version = "0.3.4", default-features = false } futures-channel = { version = "0.3.4", default-features = false }
futures-sink = { version = "0.3.4", default-features = false } futures-sink = { version = "0.3.4", default-features = false }
futures-util = { version = "0.3.4", default-features = false } futures-util = { version = "0.3.4", default-features = false }
pin-project = "0.4.6" pin-project = "0.4.17"
log = "0.4" log = "0.4"
slab = "0.4" slab = "0.4"

14
codecov.yml Normal file
View File

@@ -0,0 +1,14 @@
coverage:
status:
project:
default:
threshold: 10% # make CI green
patch:
default:
threshold: 10% # make CI green
ignore: # ignore codecoverage on following paths
- "examples"
- ".github"
- "**/*.md"
- "**/*.toml"

View File

@@ -7,7 +7,7 @@ keywords = ["actix"]
homepage = "https://actix.rs" homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-router/" documentation = "https://docs.rs/actix-router/"
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[lib] [lib]

View File

@@ -7,7 +7,7 @@ keywords = ["actix"]
homepage = "https://actix.rs" homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/bytestring/" documentation = "https://docs.rs/bytestring/"
license = "MIT/Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
[lib] [lib]

View File

@@ -1,10 +1,11 @@
//! A utl-8 encoded read-only string with Bytes as a storage. //! A UTF-8 encoded read-only string using Bytes as storage.
use std::convert::TryFrom; use std::convert::TryFrom;
use std::{borrow, fmt, hash, ops, str}; use std::{borrow, fmt, hash, ops, str};
use bytes::Bytes; use bytes::Bytes;
/// A utf-8 encoded string with [`Bytes`] as a storage. /// A UTF-8 encoded string with [`Bytes`] as a storage.
/// ///
/// [`Bytes`]: https://docs.rs/bytes/0.5.3/bytes/struct.Bytes.html /// [`Bytes`]: https://docs.rs/bytes/0.5.3/bytes/struct.Bytes.html
#[derive(Clone, Eq, Ord, PartialOrd, Default)] #[derive(Clone, Eq, Ord, PartialOrd, Default)]