Giter VIP home page Giter VIP logo

actix-net's Introduction

Actix

Actor framework for Rust

crates.io Documentation Minimum Supported Rust Version License Dependency Status
CI codecov Downloads Chat on Discord

Documentation

Features

  • Async and sync actors
  • Actor communication in a local/thread context
  • Uses futures for asynchronous message handling
  • Actor supervision
  • Typed messages (No Any type)
  • Runs on stable Rust 1.68+

Usage

To use actix, add this to your Cargo.toml:

[dependencies]
actix = "0.13"

Initialize Actix

In order to use actix you first need to create a System.

fn main() {
    let system = actix::System::new();

    system.run();
}

Actix uses the Tokio runtime. System::new() creates a new event loop. System.run() starts the Tokio event loop, and will finish once the System actor receives the SystemExit message.

Implementing an Actor

In order to define an actor you need to define a struct and have it implement the Actor trait.

use actix::{Actor, Context, System};

struct MyActor;

impl Actor for MyActor {
    type Context = Context<Self>;

    fn started(&mut self, _ctx: &mut Self::Context) {
        println!("I am alive!");
        System::current().stop(); // <- stop system
    }
}

fn main() {
    let system = System::new();

    let _addr = system.block_on(async { MyActor.start() });

    system.run().unwrap();
}

Spawning a new actor is achieved via the start and create methods of the Actor trait. It provides several different ways of creating actors; for details, check the docs. You can implement the started, stopping and stopped methods of the Actor trait. started gets called when the actor starts and stopping when the actor finishes. Check the API docs for more information on the actor lifecycle.

Handle Messages

An Actor communicates with another Actor by sending messages. In actix all messages are typed. Let's define a simple Sum message with two usize parameters and an actor which will accept this message and return the sum of those two numbers. Here we use the #[actix::main] attribute as an easier way to start our System and drive our main function so we can easily .await for the responses sent back from the Actor.

use actix::prelude::*;

// this is our Message
// we have to define the response type (rtype)
#[derive(Message)]
#[rtype(usize)]
struct Sum(usize, usize);

// Actor definition
struct Calculator;

impl Actor for Calculator {
    type Context = Context<Self>;
}

// now we need to implement `Handler` on `Calculator` for the `Sum` message.
impl Handler<Sum> for Calculator {
    type Result = usize; // <- Message response type

    fn handle(&mut self, msg: Sum, _ctx: &mut Context<Self>) -> Self::Result {
        msg.0 + msg.1
    }
}

#[actix::main] // <- starts the system and block until future resolves
async fn main() {
    let addr = Calculator.start();
    let res = addr.send(Sum(10, 5)).await; // <- send message and get future for result

    match res {
        Ok(result) => println!("SUM: {}", result),
        _ => println!("Communication to the actor has failed"),
    }
}

All communications with actors go through an Addr object. You can do_send a message without waiting for a response, or you can send an actor a specific message. The Message trait defines the result type for a message.

Actor State And Subscription For Specific Messages

You may have noticed that the methods of the Actor and Handler traits accept &mut self, so you are welcome to store anything in an actor and mutate it whenever necessary.

Address objects require an actor type, but if we just want to send a specific message to an actor that can handle the message, we can use the Recipient interface. Let's create a new actor that uses Recipient.

use actix::prelude::*;
use std::time::Duration;

#[derive(Message)]
#[rtype(result = "()")]
struct Ping {
    pub id: usize,
}

// Actor definition
struct Game {
    counter: usize,
    name: String,
    recipient: Recipient<Ping>,
}

impl Actor for Game {
    type Context = Context<Game>;
}

// simple message handler for Ping message
impl Handler<Ping> for Game {
    type Result = ();

    fn handle(&mut self, msg: Ping, ctx: &mut Context<Self>) {
        self.counter += 1;

        if self.counter > 10 {
            System::current().stop();
        } else {
            println!("[{0}] Ping received {1}", self.name, msg.id);

            // wait 100 nanoseconds
            ctx.run_later(Duration::new(0, 100), move |act, _| {
                act.recipient.do_send(Ping { id: msg.id + 1 });
            });
        }
    }
}

fn main() {
    let system = System::new();

    system.block_on(async {
        // To create a cyclic game link, we need to use a different constructor
        // method to get access to its recipient before it starts.
        let _game = Game::create(|ctx| {
            // now we can get an address of the first actor and create the second actor
            let addr = ctx.address();

            let addr2 = Game {
                counter: 0,
                name: String::from("Game 2"),
                recipient: addr.recipient(),
            }
            .start();

            // let's start pings
            addr2.do_send(Ping { id: 10 });

            // now we can finally create first actor
            Game {
                counter: 0,
                name: String::from("Game 1"),
                recipient: addr2.recipient(),
            }
        });
    });

    // let the actors all run until they've shut themselves down
    system.run().unwrap();
}

Chat Example

See this chat example which shows more comprehensive usage in a networking client/server service.

Contributing

All contributions are welcome, if you have a feature request don't hesitate to open an issue!

License

This project is licensed under either of

at your option.

Code of Conduct

Contribution to the actix repo is organized under the terms of the Contributor Covenant. The Actix team promises to intervene to uphold that code of conduct.

actix-net's People

Contributors

0xpr03 avatar aliemjay avatar asonix avatar avranju avatar c0d3d avatar dependabot[bot] avatar dowwie avatar dunnock avatar fafhrd91 avatar fakeshadow avatar georgehahn avatar ibraheemdev avatar ignatenkobrain avatar johntitor avatar jonathas-conceicao avatar miloas avatar najamelan avatar nayato avatar neoeinstein avatar neopallium avatar nujz avatar paolobarbolini avatar pka avatar popzxc avatar realaravinth avatar robjtede avatar snoyberg avatar svenstaro avatar zyctree avatar zzau13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actix-net's Issues

Tcp connection is not closed

I'm doing performance testing for an HTTP server built on actix-web.

On my server, set ulimit -n 1024 while simultaneously opening 1200 connections on another server for performance testing.

When too many open files error occurs in the HTTP server, I kill the HTTP performance test program, and then checked the server's TCP connection status (netstat -na | grep server_port) and found that many TCP connections were in the CLOSE_WAIT state and waited for several hours without release connections.

I found the code where too many open files happened.

fn accept(&mut self, token: usize) {

Based on this code I have 2 questions

  1. Will the entire HTTP server stop working after accept returns?
  2. Could it cause the connection not to drop?

Rename connect Connector to TcpConnector

Since the imports in actix-web are already renaming the import for clarity it would make sense to rename the canonical name in actix-connect to TcpConnector.

Extreme indirection with actix-server

When you want to run a TCP server, you first bind a "service factory":

pub fn bind<F, U, N: AsRef<str>>(self, name: N, addr: U, factory: F) -> Result<Self>
where
    F: ServiceFactory<TcpStream>,
    U: ToSocketAddrs,

(Despite what the type parameters initial, this is not going to be...)

So you go and look at the ServiceFactory trait...

pub trait ServiceFactory<Stream: FromStream>: Send + Clone + 'static {
    type Factory: actix::ServiceFactory<Config = (), Request = Stream>;

    fn create(&self) -> Self::Factory;
}

And find that it's not just a factory, it's a ServiceFactoryFactory! What is this, Java?

That's a minor annoyance, so let's see what it takes to implement actix::ServiceFactory:

pub trait ServiceFactory {
    type Request;
    type Response;
    type Error;
    type Config;
    type Service: Service<Request = Self::Request, Response = Self::Response, Error = Self::Error>;
    type InitError;
    type Future: Future<Output = Result<Self::Service, Self::InitError>>;
    fn new_service(&self, cfg: Self::Config) -> Self::Future;

    ...
}

Cool, so this is a factory that asynchronously produces something that implements Service. That's a little complicated but fair. Except... I don't remember seeing all these associated types being locked down.

Looking back, we see that Config is specified to be empty, and Request is specified to be a Stream. That's weird... We're only going to get one stream per connection, so why did we even need to model this as a "service". Furthermore, Response is left unspecified so presumably does not even get used.

What's going on here? Is a new service created for each connection? If that's the case why have the service trait at all? Is the same service reused for multiple connections? Then why have two levels of "service factories" and why does one of them need to be async?

Custom Cell implementation is unsound

Right now there is no mechanism in Cell to track whether a mutable reference to the data is already acquired. Thus it is possible to obtain several mutable references to the same memory location by calling Cell::get_mut() repeatedly:

let mycell = Cell::new(vec![1,2,3]);
let ref1 = mysell.get_mut();
let ref2 = mysell.get_mut(); // obtained a second mutable reference; UB starts here

This may result in pretty much arbitrary memory corruption, most likely a use-after-free. Even though no code internal to Actix makes two obvious calls to get_mut() in a row, this behavior has been shown to be exploitable from the public API (see PoC that fails MIRI).

PR #158 has removed one instance of this Cell and all uses of it. However, there is another copy of it in the repository in actix-utils crate, and there are 23 calls to .get_mut().

The obvious fix is to replace all uses of custom Cell<T> with Rc<RefCell<T>> (the way it was before the introduction of a custom cell in 20b03a4), like it was done in #158.

Reduce dependencies and achieve more independence

Tokio 0.2 maybe a big broken and futures too. like :
tokio-rs/tokio#1264
tokio-rs/tokio#1318
tokio-rs/tokio#887

I think it is hard or more time fot actix-* fellow this. should we consider Reduce tokio dependencies and achieve more independence.

at least we can port tokio-executor, tokio-current-thread to actix. we already port the actix-codec. maybe other crates can fellow if need.

I think it good for maintain, update and Contribution. is this good idea?

Do you plan to migrate from tokio to async-std when it matures ?

It seems relevant, particularly for performance reasons, to consider migration to async-std: https://async.rs/blog/stop-worrying-about-blocking-the-new-async-std-runtime/

Indeed, async-std handles blocking calls not anticipated by the developer better than tokio:

The new runtime detects blocking automatically. We don’t need spawn_blocking anymore and can simply deprecate it.

async-std also offers the advantage of not paying the cost of spawning a new thread if the blocking call is only blocking for a very short time:

The new runtime makes blocking efficient. Rather than always paying the cost of spawn_blocking, we only offload blocking work to a separate thread if the work really blocks.

So, it seems relevant to aim for a migration to async-std in the medium term, even if I understand that there are other priorities at the moment :)

Compilation error

Hi, I'm getting this compilation error after adding actix-web = "1.0" to my Cargo.toml:

   Compiling onus v0.1.0
   Compiling failure v0.1.5
   Compiling actix-codec v0.1.2
   Compiling actix-threadpool v0.1.2
   Compiling serde_urlencoded v0.6.1
   Compiling serde_json v1.0.40
   Compiling serde_urlencoded v0.5.5
   Compiling actix-router v0.1.5
   Compiling rusty_ulid v0.9.0
error: cannot find macro `log!` in this scope
   --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-codec-0.1.2/src/framed_read.rs:195:17
    |
195 |                 trace!("attempting to decode a frame");
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `log!` in this scope
   --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-codec-0.1.2/src/framed_read.rs:198:21
    |
198 |                     trace!("frame decoded from buffer");
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `log!` in this scope
   --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-codec-0.1.2/src/framed_write.rs:246:9
    |
246 |         trace!("flushing framed transport");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `log!` in this scope
   --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-codec-0.1.2/src/framed_write.rs:249:13
    |
249 |             trace!("writing; remaining={}", self.buffer.len());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `log!` in this scope
   --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-codec-0.1.2/src/framed_write.rs:270:9
    |
270 |         trace!("framed transport flushed");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `log!` in this scope
  --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-threadpool-0.1.2/src/lib.rs:21:21
   |
21 |                     log::error!("Can not parse ACTIX_THREADPOOL value");
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `log!` in this scope
   --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-router-0.1.5/src/resource.rs:206:29
    |
206 | /                             log::error!(
207 | |                                 "Dynamic path match but not all segments found: {}",
208 | |                                 name
209 | |                             );
    | |______________________________^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `log!` in this scope
   --> /Users/adaszko/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-router-0.1.5/src/resource.rs:278:29
    |
278 | /                             log::error!(
279 | |                                 "Dynamic path match but not all segments found: {}",
280 | |                                 name
281 | |                             );
    | |______________________________^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

error: Could not compile `actix-threadpool`.
warning: build failed, waiting for other jobs to finish...
error: aborting due to 5 previous errors

error: Could not compile `actix-codec`.
warning: build failed, waiting for other jobs to finish...
error: aborting due to 2 previous errors

error: Could not compile `actix-router`.
warning: build failed, waiting for other jobs to finish...
error: build failed

I'm aware of #21. I have this bit in my Cargo.toml:

[package]
[...]
edition = "2018"

This happens on both stable 1.36.0 and today's nightly.

Socket2 dependency

In version 2*, which has a dependency Socket2="0.3".
Socket2 has bumped version to 0.3.13, in which APIs like Domain::ipv4() seems dropped.

`actix-macros` isn't published to cargo.

I want to pin to master to start trying stuff out but I get:

error: no matching package named `actix-macros` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
required by package `actix-rt v1.0.0-alpha.1 (https://github.com/actix/actix-net#a0206459)`
    ... which is depended on by `actix-bb8-try v0.1.0 (/Users/b/rs/rust-service-template)

because actix-macros isn't published. I'm sure it's work in progress, but is there anyway to go ahead and publish it in an alpha version?

For now I can just patch it or use a fork of actix-rt, was just curious.

cargo test fails in actix-test-server

Here's what I currently see:

~/play/actix/actix-net/actix-test-server$ cargo test
   Compiling actix-test-server v0.1.0 (/Users/jorendorff/play/actix/actix-net/actix-test-server)
    Finished dev [unoptimized + debuginfo] target(s) in 0.66s
     Running /Users/jorendorff/play/actix/actix-net/target/debug/deps/actix_test_server-f741c12571987829

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests actix_test_server

running 1 test
test src/lib.rs - TestServer (line 20) ... FAILED

failures:

---- src/lib.rs - TestServer (line 20) stdout ----
error[E0432]: unresolved import `actix_web`
 --> src/lib.rs:22:5
  |
3 | use actix_web::*;
  |     ^^^^^^^^^ use of undeclared type or module `actix_web`

error[E0433]: failed to resolve: use of undeclared type or module `HttpResponse`
 --> src/lib.rs:25:5
  |
6 |     HttpResponse::Ok().into()
  |     ^^^^^^^^^^^^ use of undeclared type or module `HttpResponse`

error[E0412]: cannot find type `HttpRequest` in this scope
 --> src/lib.rs:24:21
  |
5 | fn my_handler(req: &HttpRequest) -> HttpResponse {
  |                     ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `HttpResponse` in this scope
 --> src/lib.rs:24:37
  |
5 | fn my_handler(req: &HttpRequest) -> HttpResponse {
  |                                     ^^^^^^^^^^^^ not found in this scope

error[E0599]: no function or associated item named `new` found for type `actix_test_server::TestServer` in the current scope
  --> src/lib.rs:31:27
   |
12 | let mut srv = TestServer::new(|app| app.handler(my_handler));
   |               ------------^^^
   |               |
   |               function or associated item not found in `actix_test_server::TestServer`

thread 'src/lib.rs - TestServer (line 20)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.


failures:
    src/lib.rs - TestServer (line 20)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--doc'

actix::io::SinkWrite is not Sync

Hello, I've had this error while using actix-codec:

error[E0277]: `std::rc::Rc<std::cell::RefCell<actix::io::InnerSinkWrite<actix_http::ws::codec::Message, futures_util::stream::stream::split::SplitSink<actix_codec::framed::Framed<awc::connect::BoxedSocket, actix_http::ws::codec::Codec>, actix_http::ws::codec::Message>>>>` cannot be shared between threads safely
  --> src/consts.rs:9:1
   |
9  | / lazy_static! {
10 | |     pub static ref AUTHZ_CLIENT: AuthzClient = {
11 | |         Runtime::new()
12 | |             .unwrap()
...  |
37 | |     };
38 | | }
   | |_^ `std::rc::Rc<std::cell::RefCell<actix::io::InnerSinkWrite<actix_http::ws::codec::Message, futures_util::stream::stream::split::SplitSink<actix_codec::framed::Framed<awc::connect::BoxedSocket, actix_http::ws::codec::Codec>, actix_http::ws::codec::Message>>>>` cannot be shared between threads safely
   |
   = help: within `model::ws::authz_client::AuthzClient`, the trait `std::marker::Sync` is not implemented for `std::rc::Rc<std::cell::RefCell<actix::io::InnerSinkWrite<actix_http::ws::codec::Message, futures_util::stream::stream::split::SplitSink<actix_codec::framed::Framed<awc::connect::BoxedSocket, actix_http::ws::codec::Codec>, actix_http::ws::codec::Message>>>>`
   = note: required because it appears within the type `actix::io::SinkWrite<actix_http::ws::codec::Message, futures_util::stream::stream::split::SplitSink<actix_codec::framed::Framed<awc::connect::BoxedSocket, actix_http::ws::codec::Codec>, actix_http::ws::codec::Message>>`
   = note: required because it appears within the type `model::ws::authz_client::AuthzClient`
   = note: required by `lazy_static::lazy::Lazy`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `acs_server`.

any idea on how to fix this?

0.8 build fails in actix-threadpool

   Compiling actix-threadpool v0.1.0
error: cannot find macro `log!` in this scope
  --> /Users/benno/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-threadpool-0.1.0/src/lib.rs:21:21
   |
21 |                     log::error!("Can not parse ACTIX_THREADPOOL value");
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

Looks like there's a missing use in actix-threadpool/src/lib.rs?

Example in README is indented confusingly

The code in README.md contains this:

            move || {
                let num = num.clone();
                let acceptor = acceptor.clone();

                // service for converting incoming TcpStream to a SslStream<TcpStream>
                (move |stream| {
                SslAcceptorExt::accept_async(&acceptor, stream)
                    .map_err(|e| println!("Openssl error: {}", e))
            })
            // convert closure to a `NewService`
            .into_new_service()

which makes it look like the .into_new_service() at the bottom is outside of the outer closure. It's not.

It looks like examples/basic.rs is indented correctly.

System::stop_on_panic is removed.

I'm using actix-rt 1.0.0 through actix 0.9.0 and observing that system does not stop on panic.
It seems like task panics get caught by tokio runtime 0.2.6.

Relevant tokio issue: tokio-rs/tokio#2002

It also seems like actix-rt 0.2 always stopped on panic due to tokio 0.1 not catching.

My current workaround is to set a panic hook that sends a stop signal to current system, so another question: is it possible to make System::with_current do nothing if current system is not set? System::current() and System::with_current require the caller to guarantee it's set.

when backpressure happen, the uds file can not be rebuild

let _ = std::fs::remove_file(path);

Hi, in my project just found that, when server is restarting, but clients is still always retry connect.
In server, get in accept fuc before WorkerAvailability, so it check all worker is not available in accept_one then into backpressure, cleanup file path.
though WorkerAvailability soon, but client can not request anymore.

is that a bug or some configure need to set?

Let's Encrypt integration

the lets-encrypt branch contains the effort to automatically handle authorization and certificate signing via Let's Encrypt. A background worker thread can be spun for auto-renewal with the intention of checking the expiration status once per week. It should be possible to rotate the certs without dropping requests by possibly queuing them when the renewal is triggered(?)

actix-server 1.0.3 does not compile

Hi me and my colleagues realized that we are not able to compile our actix-web project. We all get the following error during the build (cargo build --release):

error[E0599]: no function or associated item named `ipv4` found for struct `socket2::Domain` in the current scope
   --> /Users/Allers/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.3/src/builder.rs:491:43
    |
491 |         net::SocketAddr::V4(_) => Domain::ipv4(),
    |                                           ^^^^ function or associated item not found in `socket2::Domain`

error[E0599]: no function or associated item named `ipv6` found for struct `socket2::Domain` in the current scope
   --> /Users/Allers/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.3/src/builder.rs:492:43
    |
492 |         net::SocketAddr::V6(_) => Domain::ipv6(),
    |                                           ^^^^ function or associated item not found in `socket2::Domain`

error[E0599]: no function or associated item named `stream` found for struct `socket2::Type` in the current scope
   --> /Users/Allers/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.3/src/builder.rs:494:44
    |
494 |     let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
    |                                            ^^^^^^ function or associated item not found in `socket2::Type`

error[E0599]: no function or associated item named `tcp` found for struct `socket2::Protocol` in the current scope
   --> /Users/Allers/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.3/src/builder.rs:494:69
    |
494 |     let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
    |                                                                     ^^^ function or associated item not found in `socket2::Protocol`

error: aborting due to 4 previous errors

The cargo.toml looks like this:

[package]
name = "actix-load-test"
version = "0.1.0"
authors = ["Sven Allers <[email protected]>"]
edition = "2018"

[dependencies]
actix-web = "2.0"
actix-rt = "1.1"

The source is just a basic "Hello World!" example.

use actix_web::{web, App, HttpServer, Responder};

async fn hello_world() -> impl Responder {
    "Hello World!"
}

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .route("/", web::get().to(hello_world))
    })
    .bind("0.0.0.0:8000")?
    .run()
    .await
}

actix-rt data race

Hi. I have an app that after some times, some workers hang. (in example below, only one worker on performance test).

I try to understand what it is happening. Not all instances have the same problem at the same time.

I run the app with flag RUSTFLAGS="-Zsanitizer=thread" and a thread data race has occurred.
This the Sanitizer output.

Probably thre is an issue in my code.

==================
WARNING: ThreadSanitizer: data race (pid=215378)
  Write of size 8 at 0x7b1400005500 by thread T1:
    #0 free /rustc/llvm/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:708:3 (airline-rs+0xfed48)
    #1 alloc::alloc::dealloc::h915d50a0e4e0911e /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:92:14 (airline-rs+0xcdaae8)
    #2 _$LT$alloc..alloc..Global$u20$as$u20$core..alloc..AllocRef$GT$::dealloc::h9deebfb6a9e9eade /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:225:22 (airline-rs+0xce1a17)
    #3 _$LT$alloc..sync..Weak$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h787e6523e997fc78 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1910:22 (airline-rs+0xd629e5)
    #4 core::ptr::drop_in_place::h127f2e26be1fba1c /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd3e13b)
    #5 core::mem::drop::h018bb29f73fd6cb7 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:901:24 (airline-rs+0xcc60df)
    #6 alloc::sync::Arc$LT$T$GT$::drop_slow::h9e859fd869bfabd6 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:937:9 (airline-rs+0xd57f9b)
    #7 _$LT$alloc..sync..Arc$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h43fb9fabaa005631 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1454:13 (airline-rs+0xd6191e)
    #8 core::ptr::drop_in_place::hb9cd476ff49e5b40 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd4889b)
    #9 core::ptr::drop_in_place::h262533afccc477f0 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd3f7c9)
    #10 futures_channel::mpsc::UnboundedReceiver$LT$T$GT$::next_message::hf6d6aca8506b07e0 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-channel-0.3.5/src/mpsc/mod.rs:1164:21 (airline-rs+0xcd35ac)
    #11 _$LT$futures_channel..mpsc..UnboundedReceiver$LT$T$GT$$u20$as$u20$futures_core..stream..Stream$GT$::poll_next::h915f44c76f096180 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-channel-0.3.5/src/mpsc/mod.rs:1195:15 (airline-rs+0xce3394)
    #12 _$LT$actix_server..worker..Worker$u20$as$u20$core..future..future..Future$GT$::poll::h42609717cc05d032 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/worker.rs:323:13 (airline-rs+0xcf1c94)
    #13 actix_server::worker::Worker::start::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h0cf05407036d7c65 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/worker.rs:217:21 (airline-rs+0xcef989)
    #14 _$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h79353b790c139505 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:79:19 (airline-rs+0xcbee92)
    #15 tokio::runtime::task::core::Core$LT$T$C$S$GT$::poll::_$u7b$$u7b$closure$u7d$$u7d$::h5789aa767ba585d7 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/core.rs:173:17 (airline-rs+0xd0219c)
    #16 tokio::loom::std::unsafe_cell::UnsafeCell$LT$T$GT$::with_mut::hdce9440a0fd49eb9 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/loom/std/unsafe_cell.rs:14:9 (airline-rs+0xd603ad)
    #17 tokio::runtime::task::core::Core$LT$T$C$S$GT$::poll::h4a3b01aab0344dbb /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/core.rs:158:13 (airline-rs+0xd01089)
    #18 tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::poll::_$u7b$$u7b$closure$u7d$$u7d$::h19c393660e9ac2f7 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/harness.rs:107:27 (airline-rs+0xd72c03)
    #19 core::ops::function::FnOnce::call_once::ha4723e99ac5d119e /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (airline-rs+0xd3ccbe)
    #20 _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h463eb1fb957338d3 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:308:9 (airline-rs+0xd7960a)
    #21 std::panicking::try::do_call::h15d29db676f81814 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:381:40 (airline-rs+0xd87ccf)
    #22 __rust_try <null> (airline-rs+0xd8e37b)
    #23 std::panicking::try::h2ef2b929de56c524 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:345:19 (airline-rs+0xd85ec4)
    #24 std::panic::catch_unwind::h2b5b439b43f4349a /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:382:14 (airline-rs+0xd7d0ca)
    #25 tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::poll::h51323fdeb87c62ae /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/harness.rs:89:19 (airline-rs+0xd6fca8)
    #26 tokio::runtime::task::raw::poll::ha091826f13f8c128 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/raw.rs:104:5 (airline-rs+0xce9e1a)
    #27 tokio::runtime::task::raw::RawTask::poll::h261eb9046b520b0b /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/raw.rs:66:18 (airline-rs+0x192b5a7)
    #28 tokio::runtime::task::Notified$LT$S$GT$::run::hd0a63f8e822a1d4e /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/mod.rs:169:9 (airline-rs+0x193f533)
    #29 tokio::task::local::LocalSet::tick::_$u7b$$u7b$closure$u7d$$u7d$::h0c64e5676cdc207c /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:408:54 (airline-rs+0x192e88b)
    #30 tokio::coop::with_budget::_$u7b$$u7b$closure$u7d$$u7d$::h232660474d31b44f /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:127:9 (airline-rs+0x1928de7)
    #31 std::thread::local::LocalKey$LT$T$GT$::try_with::h259be596af85f3ae /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:271:16 (airline-rs+0x1932371)
    #32 std::thread::local::LocalKey$LT$T$GT$::with::h8e70d5e711341eef /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:247:9 (airline-rs+0x19313b8)
    #33 tokio::coop::with_budget::h5a6085d9b4b168c5 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:120:5 (airline-rs+0x192e791)
    #34 tokio::coop::budget::h21bc7f563f282e8a /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:96:5 (airline-rs+0x192e791)
    #35 tokio::task::local::LocalSet::tick::he4a8dcf7263a03b6 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:408:31 (airline-rs+0x192e791)
    #36 _$LT$tokio..task..local..RunUntil$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::_$u7b$$u7b$closure$u7d$$u7d$::hdb2e85056d3ac1b7 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:532:16 (airline-rs+0x1074d82)
    #37 tokio::macros::scoped_tls::ScopedKey$LT$T$GT$::set::h0dbedc0a8d23e6e8 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/macros/scoped_tls.rs:63:9 (airline-rs+0x1050402)
    #38 tokio::task::local::LocalSet::with::he48ca65e83bd350f /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:442:9 (airline-rs+0x107250f)
    #39 _$LT$tokio..task..local..RunUntil$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h627bc171bcd07382 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:518:9 (airline-rs+0x107449d)
    #40 tokio::task::local::LocalSet::run_until::_$u7b$$u7b$closure$u7d$$u7d$::h0e977afb30bbb3af /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:392:9 (airline-rs+0x1072ced)
    #41 _$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h2cc16559a9bdb195 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:79:19 (airline-rs+0x106426c)
    #42 tokio::runtime::basic_scheduler::BasicScheduler$LT$P$GT$::block_on::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h442a6719821c1fbf /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:131:58 (airline-rs+0x10a0a62)
    #43 tokio::coop::with_budget::_$u7b$$u7b$closure$u7d$$u7d$::ha3660b961667c582 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:127:9 (airline-rs+0x1095506)
    #44 std::thread::local::LocalKey$LT$T$GT$::try_with::h4c39097f2e97fdbe /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:271:16 (airline-rs+0x109a355)
    #45 std::thread::local::LocalKey$LT$T$GT$::with::h3a18c6a8851064c8 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:247:9 (airline-rs+0x1098048)
    #46 tokio::coop::with_budget::h78cf323ddae686bf /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:120:5 (airline-rs+0x10a010e)
    #47 tokio::coop::budget::h60382c7a95c1dcc9 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:96:5 (airline-rs+0x10a010e)
    #48 tokio::runtime::basic_scheduler::BasicScheduler$LT$P$GT$::block_on::_$u7b$$u7b$closure$u7d$$u7d$::hf2cd9ca6066c5db9 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:131:35 (airline-rs+0x10a010e)
    #49 tokio::runtime::basic_scheduler::enter::_$u7b$$u7b$closure$u7d$$u7d$::he59a880a8524cdb5 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:213:29 (airline-rs+0x10a18cc)
    #50 tokio::macros::scoped_tls::ScopedKey$LT$T$GT$::set::h1b0b2188f8bc7104 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/macros/scoped_tls.rs:63:9 (airline-rs+0x10505f2)
    #51 tokio::runtime::basic_scheduler::enter::hc2a11e63a6e1e41d /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:213:5 (airline-rs+0x10a15ee)
    #52 tokio::runtime::basic_scheduler::BasicScheduler$LT$P$GT$::block_on::h187bdab909a4d8b0 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:123:9 (airline-rs+0x109f2b8)
    #53 tokio::runtime::Runtime::block_on::_$u7b$$u7b$closure$u7d$$u7d$::h2820b6a6be981cf5 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/mod.rs:444:34 (airline-rs+0x1073521)
    #54 tokio::runtime::context::enter::h55bf50debb6357dd /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/context.rs:72:5 (airline-rs+0x1096933)
    #55 tokio::runtime::handle::Handle::enter::h9b8d1732d020a3ec /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/handle.rs:76:9 (airline-rs+0x10967e9)
    #56 tokio::runtime::Runtime::block_on::hb358befb28d3a7cf /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/mod.rs:441:9 (airline-rs+0x107318a)
    #57 tokio::task::local::LocalSet::block_on::h357ba3cbd3d2bdfd /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:353:9 (airline-rs+0x10725c0)
    #58 actix_rt::runtime::Runtime::block_on::h21d84d0f38a65ad6 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-1.1.1/src/runtime.rs:89:9 (airline-rs+0x10756a0)
    #59 actix_rt::arbiter::Arbiter::new::_$u7b$$u7b$closure$u7d$$u7d$::haf58776acf61a4f6 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-1.1.1/src/arbiter.rs:137:31 (airline-rs+0x10697ba)
    #60 std::sys_common::backtrace::__rust_begin_short_backtrace::hc8d1c4b695ae4bfc /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:137:18 (airline-rs+0x10890c6)
    #61 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h139869a882c468b4 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:461:17 (airline-rs+0x1053cba)
    #62 _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::hcc8e4ff17e6df24e /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:308:9 (airline-rs+0x106c91a)
    #63 std::panicking::try::do_call::h709cedefed39fb70 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:381:40 (airline-rs+0x10a5de9)
    #64 __rust_try <null> (airline-rs+0x10a98ab)
    #65 std::panicking::try::h0bdf66e4b92c70e2 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:345:19 (airline-rs+0x10a47b7)
    #66 std::panic::catch_unwind::haae01fa22bb6b150 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:382:14 (airline-rs+0x106e08a)
    #67 std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::h1067cbf3670aec58 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:460:30 (airline-rs+0x1053a56)
    #68 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hf4cd251c5aef05f4 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (airline-rs+0x108d5fb)
    #69 _$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::h462e787c72080422 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/alloc/src/boxed.rs:1042:9 (airline-rs+0x1e2bef9)
    #70 _$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::hd438caf7b24ea9a1 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/alloc/src/boxed.rs:1042:9 (airline-rs+0x1e2bef9)
    #71 std::sys::unix::thread::Thread::new::thread_start::h653bd369f002a164 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/sys/unix/thread.rs:87:17 (airline-rs+0x1e2bef9)

  Previous atomic write of size 8 at 0x7b1400005500 by main thread:
    #0 __tsan_atomic64_fetch_sub /rustc/llvm/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cpp:647:3 (airline-rs+0x143391)
    #1 core::sync::atomic::atomic_sub::hfc48c5fe4a3ccbcd /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2282:24 (airline-rs+0x1a2f4e5)
    #2 core::sync::atomic::AtomicUsize::fetch_sub::h714426de533c6d2c /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:1633:30 (airline-rs+0xd52a29)
    #3 _$LT$alloc..sync..Arc$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h43fb9fabaa005631 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1419:12 (airline-rs+0xd618dd)
    #4 core::ptr::drop_in_place::hb9cd476ff49e5b40 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd4889b)
    #5 core::ptr::drop_in_place::h0dd341d987190869 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd3dc32)
    #6 core::ptr::drop_in_place::h614fcc25ca3e48c0 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd42d49)
    #7 core::ptr::drop_in_place::hd91bf1904adf3e49 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd4adfb)
    #8 core::ptr::drop_in_place::h1d37c5f792ccca18 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd3eaa9)
    #9 core::ptr::drop_in_place::h574b6e274054f4f3 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd422cf)
    #10 core::ptr::drop_in_place::h781bc6c9027af93a /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd4451a)
    #11 _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hb474a5afc0ec687c /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2635:13 (airline-rs+0xc9c48b)
    #12 core::ptr::drop_in_place::hf4af1548650ff51a /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd4c89b)
    #13 core::ptr::drop_in_place::hc0b6b6fdf2b4335c /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd48d3f)
    #14 core::ptr::drop_in_place::h82c2ca110c19002b /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0xd44e27)
    #15 tokio::runtime::task::core::Core$LT$T$C$S$GT$::drop_future_or_output::_$u7b$$u7b$closure$u7d$$u7d$::h2803166d99e3164f /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/core.rs:192:22 (airline-rs+0xd0093d)
    #16 tokio::loom::std::unsafe_cell::UnsafeCell$LT$T$GT$::with_mut::h8ac88e2867d75039 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/loom/std/unsafe_cell.rs:14:9 (airline-rs+0xd5ef99)
    #17 tokio::runtime::task::core::Core$LT$T$C$S$GT$::drop_future_or_output::he2cfdcc4d42a1d9c /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/core.rs:190:9 (airline-rs+0xd006af)
    #18 tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::cancel_task::_$u7b$$u7b$closure$u7d$$u7d$::h4b246b5fbaa5abf4 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/harness.rs:293:13 (airline-rs+0xd6561f)
    #19 core::ops::function::FnOnce::call_once::hbe8ef8c57b99e4bf /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (airline-rs+0xd3cdcf)
    #20 _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h1525d728c2cce063 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:308:9 (airline-rs+0xd794fb)
    #21 std::panicking::try::do_call::h52704dbc806139a6 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:381:40 (airline-rs+0xd8820e)
    #22 __rust_try <null> (airline-rs+0xd8e37b)
    #23 std::panicking::try::hdad61456aaeaabde /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:345:19 (airline-rs+0xd8757c)
    #24 std::panic::catch_unwind::h54ef2d8af00f4387 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:382:14 (airline-rs+0xd7d24b)
    #25 tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::cancel_task::h9f2128ba4c175d00 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/harness.rs:292:19 (airline-rs+0xd648c5)
    #26 tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::shutdown::h79b0fa594af7faaf /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/harness.rs:285:9 (airline-rs+0xd786e0)
    #27 tokio::runtime::task::raw::shutdown::h6885ddb39fab4929 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/raw.rs:130:5 (airline-rs+0xceb70a)
    #28 tokio::runtime::task::raw::RawTask::shutdown::h411eeeeb3cb05306 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/raw.rs:90:18 (airline-rs+0x192b8ff)
    #29 tokio::runtime::task::Task$LT$S$GT$::shutdown::h8c2339c20eda1f17 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/mod.rs:162:9 (airline-rs+0x193f2d8)
    #30 _$LT$tokio..task..local..LocalSet$u20$as$u20$core..ops..drop..Drop$GT$::drop::_$u7b$$u7b$closure$u7d$$u7d$::h1fe801d2969eb8b1 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:494:17 (airline-rs+0x192f247)
    #31 tokio::macros::scoped_tls::ScopedKey$LT$T$GT$::set::hd77cf20dff90ce35 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/macros/scoped_tls.rs:63:9 (airline-rs+0x192707c)
    #32 tokio::task::local::LocalSet::with::hda5dce5a767a9dde /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:442:9 (airline-rs+0x192ef4f)
    #33 _$LT$tokio..task..local..LocalSet$u20$as$u20$core..ops..drop..Drop$GT$::drop::hb767c7c5b295e2cb /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:484:9 (airline-rs+0x192efd8)
    #34 core::ptr::drop_in_place::h3225570882d959e5 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0x108ecfb)
    #35 core::ptr::drop_in_place::hb413e8e651944325 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0x109200b)
    #36 core::ptr::drop_in_place::hb520dda940c651e5 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:175:1 (airline-rs+0x251c8b)
    #37 airline_rs::main::h555cd33b435b0f6f /home/fede/IdeaProjects/rust-arline/src/main.rs:43:17 (airline-rs+0x35759e)
    #38 core::ops::function::FnOnce::call_once::hc5f387d56a24fc2d /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (airline-rs+0x22a703)
    #39 std::sys_common::backtrace::__rust_begin_short_backtrace::h88c9e29ab23ee69f /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:137:18 (airline-rs+0x26afa9)
    #40 std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hbdd4d3ce48784d8b /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18 (airline-rs+0x5806d9)
    #41 core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h009d20b8a620bf60 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/core/src/ops/function.rs:259:13 (airline-rs+0x1e28500)
    #42 std::panicking::try::do_call::h09431c39e2107c90 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/panicking.rs:381:40 (airline-rs+0x1e28500)
    #43 std::panicking::try::he27cf60b958af343 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/panicking.rs:345:19 (airline-rs+0x1e28500)
    #44 std::panic::catch_unwind::h7b646b0041dc5591 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/panic.rs:382:14 (airline-rs+0x1e28500)
    #45 std::rt::lang_start_internal::hdad6c98af1e4747e /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/rt.rs:51:25 (airline-rs+0x1e28500)
    #46 main <null> (airline-rs+0x357637)

  Thread T1 'actix-rt:worker' (tid=222338, running) created by main thread at:
    #0 pthread_create /rustc/llvm/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:966:3 (airline-rs+0xffcab)
    #1 std::sys::unix::thread::Thread::new::h3c425fbab019e079 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/sys/unix/thread.rs:66:19 (airline-rs+0x1e2bc2c)
    #2 std::thread::Builder::spawn::hb4b197f84fa0d07b /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:376:18 (airline-rs+0x1053d7a)
    #3 actix_rt::arbiter::Arbiter::new::h9382bbfa3ddfaeee /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-1.1.1/src/arbiter.rs:112:22 (airline-rs+0x1068de8)
    #4 actix_server::worker::Worker::start::h5d8b00b9c730c1d6 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/worker.rs:173:9 (airline-rs+0xcede2a)
    #5 actix_server::builder::ServerBuilder::start_worker::hd20efe88d7f0ef1b /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/builder.rs:304:9 (airline-rs+0xd0851e)
    #6 actix_server::builder::ServerBuilder::run::_$u7b$$u7b$closure$u7d$$u7d$::he25167b900c288e8 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/builder.rs:268:34 (airline-rs+0xd0810b)
    #7 core::iter::adapters::map_fold::_$u7b$$u7b$closure$u7d$$u7d$::h12c0f12363bbf76b /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/mod.rs:895:28 (airline-rs+0xcb9baf)
    #8 core::iter::traits::iterator::Iterator::fold::hb53bb1df910a2602 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1988:21 (airline-rs+0xd83d15)
    #9 _$LT$core..iter..adapters..Map$LT$I$C$F$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::fold::h1587bbc7526393b0 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/mod.rs:935:9 (airline-rs+0xcbf3cf)
    #10 core::iter::traits::iterator::Iterator::for_each::hf8eb26167562f359 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:645:9 (airline-rs+0xcb8612)
    #11 _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..SpecExtend$LT$T$C$I$GT$$GT$::spec_extend::h7509658e82aa045a /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2377:17 (airline-rs+0xc9e617)
    #12 _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..SpecFromIterNested$LT$T$C$I$GT$$GT$::from_iter::h017628d7c9ef9afa /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2149:9 (airline-rs+0xca51a3)
    #13 _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..SpecFromIter$LT$T$C$I$GT$$GT$::from_iter::h4239e9cf9605ac5f /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2159:9 (airline-rs+0xca0026)
    #14 _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..iter..traits..collect..FromIterator$LT$T$GT$$GT$::from_iter::h3e7ebb1fedcfb7cd /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:1998:9 (airline-rs+0xca5c8d)
    #15 core::iter::traits::iterator::Iterator::collect::hf74eafefe1a5b859 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1637:9 (airline-rs+0xcb8096)
    #16 actix_server::builder::ServerBuilder::run::h18123b5e811bbffe /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/builder.rs:266:27 (airline-rs+0xd079da)
    #17 actix_server::builder::ServerBuilder::start::h18618c82c7affa88 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/builder.rs:255:9 (airline-rs+0xd0763a)
    #18 actix_web::server::HttpServer$LT$F$C$I$C$S$C$B$GT$::run::h8285c53524eb2eac /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-3.0.2/src/server.rs:556:9 (airline-rs+0x4f0811)
    #19 airline_rs::main::_$u7b$$u7b$closure$u7d$$u7d$::h631a547f2722c339 /home/fede/IdeaProjects/rust-arline/src/main.rs:78:5 (airline-rs+0x37a425)
    #20 _$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hf83b74ce1aa16534 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:79:19 (airline-rs+0x471168)
    #21 _$LT$tokio..task..local..RunUntil$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h3dffc581ee2b2730 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:528:65 (airline-rs+0x51339a)
    #22 tokio::coop::with_budget::_$u7b$$u7b$closure$u7d$$u7d$::hf5c67737dbf2cc73 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:127:9 (airline-rs+0x528c64)
    #23 std::thread::local::LocalKey$LT$T$GT$::try_with::hfd17927c54d1d19b /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:271:16 (airline-rs+0x4631a3)
    #24 std::thread::local::LocalKey$LT$T$GT$::with::hb8d7667a6924cc87 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:247:9 (airline-rs+0x45fba6)
    #25 tokio::coop::with_budget::hd4723784df0ad4cf /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:120:5 (airline-rs+0x513154)
    #26 tokio::coop::budget::hb533e00f392b5a9e /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:96:5 (airline-rs+0x513154)
    #27 _$LT$tokio..task..local..RunUntil$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::_$u7b$$u7b$closure$u7d$$u7d$::h159d8cec9478f005 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:528:42 (airline-rs+0x513154)
    #28 tokio::macros::scoped_tls::ScopedKey$LT$T$GT$::set::hf5707a02094ec983 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/macros/scoped_tls.rs:63:9 (airline-rs+0x4c61dc)
    #29 tokio::task::local::LocalSet::with::ha6c745995dc0440f /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:442:9 (airline-rs+0x5127ad)
    #30 _$LT$tokio..task..local..RunUntil$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hfd860b4a2685e23d /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:518:9 (airline-rs+0x512e97)
    #31 tokio::task::local::LocalSet::run_until::_$u7b$$u7b$closure$u7d$$u7d$::hb9c4384c5b1c752b /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:392:9 (airline-rs+0x512be7)
    #32 _$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h53f18bae8a604ca6 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:79:19 (airline-rs+0x46a238)
    #33 tokio::runtime::basic_scheduler::BasicScheduler$LT$P$GT$::block_on::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h5ea7fdde5cc2abe7 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:131:58 (airline-rs+0x593a7c)
    #34 tokio::coop::with_budget::_$u7b$$u7b$closure$u7d$$u7d$::hdd033e114f1c4933 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:127:9 (airline-rs+0x528904)
    #35 std::thread::local::LocalKey$LT$T$GT$::try_with::he7f178f6db31397f /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:271:16 (airline-rs+0x462723)
    #36 std::thread::local::LocalKey$LT$T$GT$::with::h3821214bf7497fe2 /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:247:9 (airline-rs+0x45eff6)
    #37 tokio::coop::with_budget::h0d917a74990a4bea /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:120:5 (airline-rs+0x593241)
    #38 tokio::coop::budget::h5a98a82aefa698f5 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/coop.rs:96:5 (airline-rs+0x593241)
    #39 tokio::runtime::basic_scheduler::BasicScheduler$LT$P$GT$::block_on::_$u7b$$u7b$closure$u7d$$u7d$::hbd9686fab542931d /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:131:35 (airline-rs+0x593241)
    #40 tokio::runtime::basic_scheduler::enter::_$u7b$$u7b$closure$u7d$$u7d$::h522bd2b32ecab58e /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:213:29 (airline-rs+0x5941ec)
    #41 tokio::macros::scoped_tls::ScopedKey$LT$T$GT$::set::hdcb59b6cceed5d90 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/macros/scoped_tls.rs:63:9 (airline-rs+0x4c5fec)
    #42 tokio::runtime::basic_scheduler::enter::h7b1ab12d2fe4eaa5 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:213:5 (airline-rs+0x593ff5)
    #43 tokio::runtime::basic_scheduler::BasicScheduler$LT$P$GT$::block_on::hb2c64b4f960fbd16 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/basic_scheduler.rs:123:9 (airline-rs+0x592ecf)
    #44 tokio::runtime::Runtime::block_on::_$u7b$$u7b$closure$u7d$$u7d$::h9ca96e1566f5858f /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/mod.rs:444:34 (airline-rs+0x281c25)
    #45 tokio::runtime::context::enter::hd7785a3a01114489 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/context.rs:72:5 (airline-rs+0x3b3a8d)
    #46 tokio::runtime::handle::Handle::enter::h660a8eebf6b21ef6 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/handle.rs:76:9 (airline-rs+0x2a6127)
    #47 tokio::runtime::Runtime::block_on::h8d8e91e9f475d966 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/mod.rs:441:9 (airline-rs+0x281988)
    #48 tokio::task::local::LocalSet::block_on::hc1abab96a185a66e /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/task/local.rs:353:9 (airline-rs+0x51288c)
    #49 actix_rt::runtime::Runtime::block_on::h31808a4024c772cf <null> (airline-rs+0x324e3d)
    #50 actix_rt::builder::SystemRunner::block_on::hd24a9b8cc198f646 /home/fede/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-1.1.1/src/builder.rs:187:19 (airline-rs+0x26bcad)
    #51 airline_rs::main::h555cd33b435b0f6f /home/fede/IdeaProjects/rust-arline/src/main.rs:43:1 (airline-rs+0x357584)
    #52 core::ops::function::FnOnce::call_once::hc5f387d56a24fc2d /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 (airline-rs+0x22a703)
    #53 std::sys_common::backtrace::__rust_begin_short_backtrace::h88c9e29ab23ee69f /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:137:18 (airline-rs+0x26afa9)
    #54 std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hbdd4d3ce48784d8b /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18 (airline-rs+0x5806d9)
    #55 core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h009d20b8a620bf60 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/core/src/ops/function.rs:259:13 (airline-rs+0x1e28500)
    #56 std::panicking::try::do_call::h09431c39e2107c90 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/panicking.rs:381:40 (airline-rs+0x1e28500)
    #57 std::panicking::try::he27cf60b958af343 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/panicking.rs:345:19 (airline-rs+0x1e28500)
    #58 std::panic::catch_unwind::h7b646b0041dc5591 /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/panic.rs:382:14 (airline-rs+0x1e28500)
    #59 std::rt::lang_start_internal::hdad6c98af1e4747e /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/std/src/rt.rs:51:25 (airline-rs+0x1e28500)
    #60 main <null> (airline-rs+0x357637)

SUMMARY: ThreadSanitizer: data race /home/fede/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:92:14 in alloc::alloc::dealloc::h915d50a0e4e0911e
==================
ThreadSanitizer: reported 1 warnings

Tracking issue for std::future migration

This issue tracks the migration.

Crates migrated:

  • - actix-threadpool #46
  • - actix-rt #47
  • - actix-codec #48
  • - actix-service (discussion needed) #57
  • - actix-server-config (Needs bugfixing)
  • - actix-server (Needs bugfixing)
  • - actix-utils
  • - actix-connect
  • - actix-ioframe

note: these are in rough dependency order

Decisions:

  1. The old future trait had Item, and Error associated types. This meant it was similar to the Result type, and thus, every function that returned future was fallible. Now, the future has only one associated type, that denotes infallible future output.

    Several places return a future with a result, that is not used anywhere, or its error type is (). Which of these occurences should be replaced with Future<Output=Item>, and which with Future<Output=Result<Item,Error>>?

  2. Usage of the Pin<&mut Self> in places similar to future, this means the Service::poll_ready and ActorFuture::poll in actix.

    There is a reason for using these Pins in the poll method, should we upgrade our definitions of
    traits similar to Future to also utilize them ?. Also, maybe not, since these were primarily introduced to support await in the form of generators. Need more info from qualified people.

  3. Usage and form of macros / functions to ease pinning and unpinning.

    I am currently working on actix-service, and it is a massive chore to always create unsafe block in
    order to create or destrucure a Pin<&mut T>. This can be sometimes solved by pin projections from the pin-utils crate, but it does not allow splitting borrows ( Creating multiple pins to multiple fields of a struct), which is a massive pain.

actix-rt: unexpected panic at 'System is not running'

I've been experimenting with actix-net and actix and I found a weird bug when building from github.

// [dependencies]
// actix = "0.9"
// actix-rt = { git = "https://github.com/actix/actix-net" }

use actix::prelude::*;

struct Foo;

impl Actor for Foo {
    type Context = Context<Self>;
}

#[test]
fn bar() {
    actix_rt::System::new("test").block_on(async {
        let act = Foo;
        act.start();
    })
}

This panics on start when it eventually calls for actix_rt::spawn.

Using a more basic spawn, like actix_rt::spawn(async {}) doesn't cause any panic.

If I use the released version, actix-rt = "1", everything runs as expected, but if I set the dependency to actix-rt = { git = "https://github.com/actix/actix-net", rev = "rt-1.0.0" } I still get the weird panic. I haven't been able to figure out what causes the problem so far, but I'll continue to search soon, any insight would be appreciated.

The panic message:

failures:

---- bar stdout ----
thread 'main' panicked at 'System is not running', <::std::macros::panic macros>:2:4
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Panic in Arbiter thread.

actix-rt: leaking memory in every request

I just compiled example from github and run apache benchmarks ab -n 1000000 -c 64 http://127.0.0.1:8001/test/john/index.html and memory was constantly growing. After 1 milion requests it was 3.1 GB of heap.

I could reproduce the same on my catalina macbook pro and linux server. It's like every request is leaking few KB's of memory.

actix-connect : use of unstable library feature 'copied'

I'm doing a build using actix-web 1.0.5 and actix 0.8.3 and getting the following error when the dependencies are compiling for cargo build --release

This is from a docker image rust:latest or 1.36

error[E0658]: use of unstable library feature 'copied' (see issue #57126)
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-connect-0.2.1/src/connect.rs:152:56

Chaining `bind` and `bind_rustls`/`bind_openssl` on the same port.

With @fafhrd91's help I figured out how to chain HttpServices with the goal to upgrade connections from http to https by redirection.

I was thinking it might be very useful to implement this on a high-level e.g. actix-web. Would that be acceptable or is this out of scope? I am willing to implement this myself.

actix_rt::spawn `Output = ()` constraint

Migrating to Actix-web 2.0 (thanks btw! 👏)

I used tokio::spawn(...) which had a return value. Since this doesn't work with #[actix_rt::main] I'm trying to rather make use of actix_rt::spawn but I see it has a constraint of Output = ()

Is it possible to remove this constraint, or (probably) am I going about this the wrong way?

error[E0658]: use of unstable library feature 'matches_macro'

I am getting the following error when trying to compile a crate that depends on actix-utils:

error[E0658]: use of unstable library feature 'matches_macro'
  --> /home/jared/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-2.0.0/src/timeout.rs:61:38
   |
61 |             TimeoutError::Timeout => matches!(other, TimeoutError::Timeout),
   |                                      ^^^^^^^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/65721

error: aborting due to previous error

The error in question was closed in October of 2019, but the compiler is complaining about line 61 in timeout.rs.

I am on Ubuntu on WSL(Windows Subsystem for Linux), and have the following versions of Rust tooling:

  • rustup 1.21.1
  • rustc 1.41.1
  • cargo 1.41.0

My rustup toolchain is: stable-x86_64-unknown-linux-gnu (default).

I have the following Actix related dependencies in the project:

actix = { version="0.9.0", features=["http"] }
actix-multipart = "0.2.0"
actix-web = "2.0.0"
actix-rt = "1.0.0"
async-std = "1.4.0"
actix-cors = "0.2.0"
actix-web-httpauth = "0.4.1"

What could be causing this issue? I have successfully compiled this project within the last month and have never seen this problem before.

parking_lot 0.8

Is there any specific reason parking_lot was not updated to 0.8 or just some oversight?

due to 'actix-server' upgrade to 1.0.4, not compiled in rust 1.41.1 version

that actix-server upgrade 1.0.3 to 1.0.4 version.,that changed actix-utils from 1.0.6 to 2.0.0.

In rust 1.41.1 version, not supported matches! macro. below detail error:

checking actix-utils v2.0.0
error[E0658]: use of unstable library feature 'matches_macro'
  --> .cargo/registry/src/actix-utils-2.0.0/src/timeout.rs:61:38
   |
61 |             TimeoutError::Timeout => matches!(other, TimeoutError::Timeout),
   |                                      ^^^^^^^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/65721

error: aborting due to previous error

Include LICENSE-* files into all sub-crates

I'm packaging actix-* for Fedora and I noticed that on tarballs from crates.io, there are no LICENSE files. I believe that this is one of legal requirements of Apache-2.0. I think creating symlink in each directory and publishing new version should do the trick.

Thanks!

The Tokio runtime is not customizable for workers

Expected Behavior

Using actix_rt::System::run_in_tokio I can run Actix with a custom Tokio runtime. Specifically, I want to use the tokio-compat runtime so I can support legacy Tokio 0.1 code.

Current Behavior

Using actix_rt::System::run_in_tokio only runs the main "thread" or future under the custom runtime. Workers still use the default runtime (link to relevant code).

Possible Solution

Provide a way to pass a runtime or runtime factory to Actix for its use.

Steps to Reproduce (for bugs)

  1. Clone and run https://github.com/Mcat12/actix-compat-runtime-crash
  2. See that the spawned Tokio 0.1 and 0.2 futures ran (they print a message)
  3. Go to http://127.0.0.1:8000/
  4. See that the worker has panicked with "called Result::unwrap() on an Err value: SpawnError { is_shutdown: true }"

Context

I need to use a crate which uses Tokio 0.1 (and futures 0.1). This crate sometimes spawns new futures (Hyper 0.12 client). This fails because there is no Tokio 0.1 executor.

Previous related issues:

Your Environment

  • Rust Version (I.e, output of rustc -V): 1.44.1
  • Actix Web Version: 2.0.0

Connection not closed properly

I've been using 1.x version of actix-web for months, had to restart my app every now and then (sometimes after minutes, sometimes after days) since there are a lot of ESTABLISHED connections left there hanging, eventually causing too many open files error (I've increased the limit drastically). I'm using my server with keep-alive disabled, the rest of the settings are the defaults. I have since tried to upgrade to 2.0.0 to see if it solves the problem, but it's the same thing.

The service itself gets around 500-1000 requests per second in production currently.

manually setting workers(0) will actually spin 0 thread

Just a little thing, I noticed. at server building when you set .workers(0) then it will actually spin 0 threads and no request goes though. My expectation was that by setting 0, it would load whatever the default value for workers would be. Is it a bug or desired behavior? If bug, I'd be glad to send a PR.
right now with: actix-web "3.0.0-beta.1"

Create more example apps

I'm trying to understand how to use actix-net to write simple networking code. However due to being unfamiliar with the nomenclature it is hard to navigate the documentation.

It might help to have (my guess is based on features I think are in):

  • Line-based echo application (I guess it might allow to present transformation from bytes to strings and from strings to lines?)
  • Line-based chat server (above + reply to clients not directed at their request)

Complier the code twice(linux system),the executable file has difference

I complier the code twice(linux system),and compare the first executable file and second file by the "Beyond Compare",there has a difference.When i remove the line let service: BoxedServerService = Box::new(StreamService::new(inner));,the two executable file has no difference.

let service: BoxedServerService = Box::new(StreamService::new(inner));

The main.rs

use actix_web::{web, App, Responder, HttpServer};

async fn index() -> impl Responder {
    "Hello world!"
}

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new().service(
            web::scope("/app").route("/index.html", web::get().to(index)),
        )
    })
        .bind("127.0.0.1:8088")?
        .run()
        .await
}

Cargo.toml

[package]
name = "test1"
version = "0.1.0"
authors = [""]
edition = "2018"

[dependencies]
actix-web = {version = "=2.0.0", features=["rust-tls"] }
actix-rt = "=1.0.0"

UB due to unsafe pinning in actix-codec

The following code segfaults, due to incorrect pinning in Framed.

use futures::task::{noop_waker, Context, Poll};
use actix_codec::{Framed, AsyncRead, BytesCodec, AsyncWrite};
use std::pin::Pin;
use futures::io::Error;
use std::future::Future;
use pin_project::pin_project;

#[pin_project]
struct FakeSocket<F> {
    #[pin]
    inner: F
}

impl<F: Future> AsyncRead for FakeSocket<F> {
    fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize, Error>> {
        self.project().inner.poll(cx).map(|x| Ok(0))
    }
}

impl<F> AsyncWrite for FakeSocket<F> {
    fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, Error>> {
        unimplemented!()
    }

    fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
        unimplemented!()
    }

    fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
        unimplemented!()
    }
}

fn main() {
    let (sender, receiver) = futures::channel::oneshot::channel();
    let mut framed: Result<_, [u8; 32]> = Ok(Framed::new(FakeSocket {
        inner: async {
            let x = Box::new(0);
            let y = &x;
            receiver.await.unwrap();
            let z = **y;
        }
    }, BytesCodec));

    let waker = noop_waker();
    let mut context = Context::from_waker(&waker);

    framed.as_mut().unwrap().next_item(&mut context);
    sender.send(()).unwrap();
    let _ = std::mem::replace(&mut framed, Err([0; 32])).unwrap().next_item(&mut context);
}

Instructions in examples/basic.rs don't work

I'm probably doing something dumb, but the file says:

//! simple composite service
//! build: cargo run --example basic --features "ssl"

And I get:

~/play/actix/actix-net/examples$ cargo run --example basic --features "ssl"
error: no example target named `basic`

Fresh project fails to compile due to dep

I am not sure how deep to go on this but it looks like the trust-dns-proro v0.18.0-alpha.2 has a compile error in failure_derive dep

error[E0433]: failed to resolve: could not find `__rt` in `quote`
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/failure_derive-0.1.6/src/lib.rs:107:70
    |
107 | fn display_body(s: &synstructure::Structure) -> Result<Option<quote::__rt::TokenStream>, Error> {
    |                                                                      ^^^^ could not find `__rt` in `quote`

error: aborting due to previous error

looking at my dep tree:

│   │   │   ├── trust-dns-proto v0.18.0-alpha.2
│   │   │   │   ├── async-trait v0.1.22        
│   │   │   │   │   ├── proc-macro2 v1.0.6 (*)
│   │   │   │   │   ├── quote v1.0.2 (*)
│   │   │   │   │   └── syn v1.0.11 (*)
│   │   │   │   ├── enum-as-inner v0.3.0
│   │   │   │   │   ├── heck v0.3.1   
│   │   │   │   │   │   └── unicode-segmentation v1.6.0
│   │   │   │   │   ├── proc-macro2 v1.0.6 (*)
│   │   │   │   │   ├── quote v1.0.2 (*)
│   │   │   │   │   └── syn v1.0.11 (*)       
│   │   │   │   ├── failure v0.1.6                
│   │   │   │   │   ├── backtrace v0.3.40
│   │   │   │   │   │   ├── backtrace-sys v0.1.32 
│   │   │   │   │   │   │   └── libc v0.2.66 (*)
│   │   │   │   │   │   │   [build-dependencies]  
│   │   │   │   │   │   │   └── cc v1.0.47 
│   │   │   │   │   │   │       ├── jobserver v0.1.17
│   │   │   │   │   │   │       │   ├── libc v0.2.66 (*)
│   │   │   │   │   │   │       │   └── log v0.4.8 (*)
│   │   │   │   │   │   │       └── num_cpus v1.11.1 (*)
│   │   │   │   │   │   ├── cfg-if v0.1.10 (*)
│   │   │   │   │   │   ├── libc v0.2.66 (*)       
│   │   │   │   │   │   └── rustc-demangle v0.1.16 
│   │   │   │   │   └── failure_derive v0.1.6 

I reverted to an older version of my Cargo.lock file so it thankfully compiles. Is it necessary to open this issue somewhere else?

thread 'actix-rt:worker:1' panicked at 'called `Result::unwrap()` on an `Err` value: ()'

This is a weird one. So I have a web server written in actix and a reverse proxy written in actix. I'm using a simple set up with these two services: curl -> reverse proxy -> web server. This works just fine. However, when I run that set up in Docker, I get this:

thread 'actix-rt:worker:0' panicked at 'called `Result::unwrap()` on an `Err` value: ()', src/libcore/result.rs:1084:5
stack backtrace:
   0:          0x14e6952 - backtrace::backtrace::libunwind::trace::h23a1372728ae23d0
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/libunwind.rs:88
   1:          0x14e6952 - backtrace::backtrace::trace_unsynchronized::h7c93075f10fab669
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/mod.rs:66
   2:          0x14e6952 - std::sys_common::backtrace::_print::ha066fa82ede9fd87
                               at src/libstd/sys_common/backtrace.rs:47
   3:          0x14e6952 - std::sys_common::backtrace::print::hed1589cd35280fb7
                               at src/libstd/sys_common/backtrace.rs:36
   4:          0x14e6952 - std::panicking::default_hook::{{closure}}::hd861923931ed9089
                               at src/libstd/panicking.rs:200
   5:          0x14e6636 - std::panicking::default_hook::h9b7b335db906b95d
                               at src/libstd/panicking.rs:214
   6:          0x14e70a5 - std::panicking::rust_panic_with_hook::h9ab61e4bfd455f53
                               at src/libstd/panicking.rs:477
   7:          0x14e6c42 - std::panicking::continue_panic_fmt::hd3ae5a0983e1ec4a
                               at src/libstd/panicking.rs:384
   8:          0x14e6b36 - rust_begin_unwind
                               at src/libstd/panicking.rs:311
   9:          0x150ca7a - core::panicking::panic_fmt::hd549f33df856c689
                               at src/libcore/panicking.rs:85
  10:          0x150cb77 - core::result::unwrap_failed::haa0856db93fbf3af
                               at src/libcore/result.rs:1084
  11:           0x86b1e0 - core::result::Result<T,E>::unwrap::h031e020cf820b88c
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libcore/result.rs:852
  12:           0x8316d8 - <actix_connect::ssl::rustls::RustlsConnectorService<T,U> as actix_service::Service>::call::h8a3ba52545ef1fa8
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-connect-0.2.5/src/ssl/rustls.rs:100
  13:           0x8b692e - <actix_service::map_err::MapErr<A,F,E> as actix_service::Service>::call::h244bfec4a5cf2a92
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/map_err.rs:61
  14:           0x800f5e - <actix_service::map::Map<A,F,Response> as actix_service::Service>::call::h1adc0109b3d9b4f9
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/map.rs:60
  15:           0x8b5266 - <actix_service::boxed::ServiceWrapper<T> as actix_service::Service>::call::hf8d1132ca7f24f43
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/boxed.rs:144
  16:           0x8e6a01 - <alloc::boxed::Box<S> as actix_service::Service>::call::h3dfa124ade339f5d
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/lib.rs:369
  17:           0x8ebfed - <actix_service::and_then::AndThenFuture<A,B> as futures::future::Future>::poll::haebe3dc9620b3a7b
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/and_then.rs:102
  18:           0x9108cf - <actix_utils::timeout::TimeoutServiceResponse<T> as futures::future::Future>::poll::hba40e94254fff9be
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-0.4.5/src/timeout.rs:161
  19:           0x8ba0be - <actix_service::map_err::MapErrFuture<A,F,E> as futures::future::Future>::poll::hc81cd47ae3702438
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/map_err.rs:93
  20:           0x8bb1d1 - <actix_http::client::pool::OpenConnection<F,Io> as futures::future::Future>::poll::h6b6b8d5e42479310
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-http-0.2.10/src/client/pool.rs:270
  21:           0x908fca - <futures::future::either::Either<A,B> as futures::future::Future>::poll::hf12abf2dcbcb01b0
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/either.rs:36
  22:           0x9087ca - <futures::future::either::Either<A,B> as futures::future::Future>::poll::h096a80bb52c3ff6f
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/either.rs:36
  23:           0x7c9e4a - <actix_http::client::connector::connect_impl::InnerConnectorResponseB<T,Io1,Io2> as futures::future::Future>::poll::h9bb0a671f7cee801
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-http-0.2.10/src/client/connector.rs:534
  24:           0x908d4a - <futures::future::either::Either<A,B> as futures::future::Future>::poll::hb60c170b92d0e97c
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/either.rs:36
  25:           0x9088ca - <futures::future::either::Either<A,B> as futures::future::Future>::poll::h2b08b5dfc258caba
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/either.rs:36
  26:           0x8ea422 - <futures::future::from_err::FromErr<A,E> as futures::future::Future>::poll::h05b9f9067cb7ec25
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/from_err.rs:29
  27:           0x8d95af - futures::future::chain::Chain<A,B,C>::poll::hf2c344d6a8ef4aa5
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/chain.rs:26
  28:           0x84af8e - <futures::future::and_then::AndThen<A,B,F> as futures::future::Future>::poll::h842a9f10643c9e36
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/and_then.rs:32
  29:           0x906922 - <futures::future::map::Map<A,F> as futures::future::Future>::poll::h686950db7a0e568e
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/map.rs:30
  30:           0x8e6b20 - <alloc::boxed::Box<F> as futures::future::Future>::poll::he6fd8ca437c7fd76
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/mod.rs:113
  31:           0x8ec603 - <awc::sender::SendClientRequest as futures::future::Future>::poll::h7a335ade87b5e3c2
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/awc-0.2.7/src/sender.rs:82
  32:           0x4351da - <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::h72182557316c9279
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/map_err.rs:30
  33:           0x4300e1 - <futures::future::map::Map<A,F> as futures::future::Future>::poll::h263aa1f81508716b
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/map.rs:30
  34:           0x4dd6e8 - <actix_web::handler::AsyncHandlerServiceResponse<T> as futures::future::Future>::poll::hf1edfd33209cc7d2
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-1.0.8/src/handler.rs:249
  35:           0x4de7c0 - <actix_web::handler::ExtractResponse<T,S> as futures::future::Future>::poll::h5d3ebc282448cc32
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-1.0.8/src/handler.rs:361
  36:           0x4e0220 - futures::future::chain::Chain<A,B,C>::poll::h1925403f4da92b97
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/chain.rs:26
  37:           0x4dbf1d - <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::h18fed1d27521182e
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/then.rs:32
  38:           0x79dcf0 - <alloc::boxed::Box<F> as futures::future::Future>::poll::h7253149fb66b9f19
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/mod.rs:113
  39:           0x79619a - <futures::future::either::Either<A,B> as futures::future::Future>::poll::h5060d2a3d917dfdf
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/either.rs:36
  40:           0x79dcf0 - <alloc::boxed::Box<F> as futures::future::Future>::poll::h7253149fb66b9f19
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/mod.rs:113
  41:           0x79619a - <futures::future::either::Either<A,B> as futures::future::Future>::poll::h5060d2a3d917dfdf
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/either.rs:36
  42:           0x4d294b - actix_http::h1::dispatcher::InnerDispatcher<T,S,B,X,U>::poll_response::hbb7880595ac84800
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-http-0.2.10/src/h1/dispatcher.rs:381
  43:           0x4c4657 - <actix_http::h1::dispatcher::Dispatcher<T,S,B,X,U> as futures::future::Future>::poll::h35ca21642a64c6c7
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-http-0.2.10/src/h1/dispatcher.rs:727
  44:           0x4be597 - <actix_http::service::HttpServiceHandlerResponse<T,S,B,X,U> as futures::future::Future>::poll::h439913f08ef31d66
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-http-0.2.10/src/service.rs:464
  45:           0x42fd6b - <actix_service::map_err::MapErrFuture<A,F,E> as futures::future::Future>::poll::h8eba52320b99bbee
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/map_err.rs:93
  46:           0x485f28 - <actix_service::and_then::AndThenFuture<A,B> as futures::future::Future>::poll::h0e77d965810fd100
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-service-0.4.2/src/and_then.rs:96
  47:           0x4e0e32 - futures::future::chain::Chain<A,B,C>::poll::h6e1ad57049fed90e
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/chain.rs:26
  48:           0x4dbf46 - <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::h93859fb36bc3aadc
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/then.rs:32
  49:           0x4b7b36 - <alloc::boxed::Box<F> as futures::future::Future>::poll::hb3a3ae21f8c15b2f
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/mod.rs:113
  50:           0xdb6058 - <alloc::boxed::Box<F> as futures::future::Future>::poll::h963e6ae22feeaa51
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/future/mod.rs:113
  51:           0xdbac04 - futures::task_impl::Spawn<T>::poll_future_notify::{{closure}}::h297563f5b373ac39
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/task_impl/mod.rs:329
  52:           0xdbb1a4 - futures::task_impl::Spawn<T>::enter::{{closure}}::h42c258f3be180436
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/task_impl/mod.rs:399
  53:           0xdc5514 - futures::task_impl::std::set::h6e12adcafc7abbc1
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/task_impl/std/mod.rs:83
  54:           0xdbb0ff - futures::task_impl::Spawn<T>::enter::h878fd896e7f1c676
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/task_impl/mod.rs:399
  55:           0xdba8e5 - futures::task_impl::Spawn<T>::poll_fn_notify::h5d72cbec9e6ba54e
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/task_impl/mod.rs:291
  56:           0xdbab18 - futures::task_impl::Spawn<T>::poll_future_notify::h4535b8ea296cf39d
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.29/src/task_impl/mod.rs:329
  57:           0xdcb5d7 - tokio_current_thread::scheduler::Scheduled<U>::tick::h4b64fc1ef04bd453
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/scheduler.rs:351
  58:           0xdcc2a4 - tokio_current_thread::scheduler::Scheduler<U>::tick::{{closure}}::hfc79c46169fe00d3
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/scheduler.rs:330
  59:           0xdc71b4 - tokio_current_thread::Borrow<U>::enter::{{closure}}::{{closure}}::h2dab440be4dc5a46
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/lib.rs:788
  60:           0xdc6b93 - tokio_current_thread::CurrentRunner::set_spawn::hdc705e415144b127
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/lib.rs:825
  61:           0xdc7088 - tokio_current_thread::Borrow<U>::enter::{{closure}}::h73b2126db847ae09
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/lib.rs:788
  62:           0xdb0838 - std::thread::local::LocalKey<T>::try_with::hd6aace9a5617dada
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:262
  63:           0xdadd58 - std::thread::local::LocalKey<T>::with::hba65eac1eb3cde7d
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:239
  64:           0xdc6d7e - tokio_current_thread::Borrow<U>::enter::heed68cf146e8bfd5
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/lib.rs:786
  65:           0xdcc1a6 - tokio_current_thread::scheduler::Scheduler<U>::tick::h25f256566955619e
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/scheduler.rs:330
  66:           0xdc742d - tokio_current_thread::Entered<P>::tick::hf7976717860d0ba1
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/lib.rs:612
  67:           0xdc7980 - tokio_current_thread::Entered<P>::block_on::h97bc414d24393e00
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-current-thread-0.1.6/src/lib.rs:502
  68:           0xdbbbde - actix_rt::runtime::Runtime::block_on::{{closure}}::hec5c602b940d208a
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/runtime.rs:128
  69:           0xdbc1b1 - actix_rt::runtime::Runtime::enter::{{closure}}::{{closure}}::{{closure}}::{{closure}}::hbdc236d83ce41a02
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/runtime.rs:168
  70:           0xde319d - tokio_executor::global::with_default::{{closure}}::h69fdbe1499110400
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-executor-0.1.8/src/global.rs:209
  71:           0xdb0318 - std::thread::local::LocalKey<T>::try_with::h9a289e10fe88e4ee
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:262
  72:           0xdad83c - std::thread::local::LocalKey<T>::with::h547a23ab6fdb590b
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:239
  73:           0xde3062 - tokio_executor::global::with_default::hfa3b9d2777d9dc7a
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-executor-0.1.8/src/global.rs:178
  74:           0xdbc3de - actix_rt::runtime::Runtime::enter::{{closure}}::{{closure}}::{{closure}}::hc776cd59025edf48
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/runtime.rs:166
  75:           0xdd47d2 - tokio_timer::timer::handle::with_default::{{closure}}::hb17f316a8924784d
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-timer-0.2.11/src/timer/handle.rs:101
  76:           0xdae548 - std::thread::local::LocalKey<T>::try_with::h099fac83787588be
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:262
  77:           0xdad73c - std::thread::local::LocalKey<T>::with::h4df2963c0c9d86ec
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:239
  78:           0xdd3f95 - tokio_timer::timer::handle::with_default::h7773d178fbc343c8
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-timer-0.2.11/src/timer/handle.rs:84
  79:           0xdbc569 - actix_rt::runtime::Runtime::enter::{{closure}}::{{closure}}::h9f06767876690b5c
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/runtime.rs:159
  80:           0xdaa318 - tokio_timer::clock::clock::with_default::{{closure}}::h720b3d8750b410f6
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-timer-0.2.11/src/clock/clock.rs:137
  81:           0xdaeec4 - std::thread::local::LocalKey<T>::try_with::h2cf4ccffbe4faf75
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:262
  82:           0xdad5ad - std::thread::local::LocalKey<T>::with::h30cac76df5a9ff8c
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:239
  83:           0xda9ffe - tokio_timer::clock::clock::with_default::hae6b31e02e766c7b
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-timer-0.2.11/src/clock/clock.rs:117
  84:           0xdbc60d - actix_rt::runtime::Runtime::enter::{{closure}}::h34cc78a37498d1fb
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/runtime.rs:158
  85:           0xdd4cbf - tokio_reactor::with_default::{{closure}}::h00910751dcf03322
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-reactor-0.1.10/src/lib.rs:237
  86:           0xdb09c4 - std::thread::local::LocalKey<T>::try_with::hd8e19bac2fa83819
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:262
  87:           0xdad7bd - std::thread::local::LocalKey<T>::with::h4e319e7059abb380
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/local.rs:239
  88:           0xdd4a98 - tokio_reactor::with_default::hae0eb15589bf0fb0
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-reactor-0.1.10/src/lib.rs:217
  89:           0xdbbd0c - actix_rt::runtime::Runtime::enter::h3cc288abb674bd32
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/runtime.rs:157
  90:           0xdbba08 - actix_rt::runtime::Runtime::block_on::h5c9158a7a069e9f1
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/runtime.rs:126
  91:           0xddbf93 - actix_rt::arbiter::Arbiter::new::{{closure}}::h608762cb554dee26
                               at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-0.2.5/src/arbiter.rs:113
  92:           0xdc8d35 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd39392a9b098cc23
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/sys_common/backtrace.rs:77
  93:           0xdbea41 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::h21fd417bea5cdb08
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/mod.rs:470
  94:           0xdb0e64 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h97c648887094eeb7
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/panic.rs:315
  95:           0xde3c8e - std::panicking::try::do_call::h202a11e8e863fd25
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/panicking.rs:296
  96:          0x14ea53a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  97:           0xde3af0 - std::panicking::try::he2207e60ab1cb385
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/panicking.rs:275
  98:           0xdb1456 - std::panic::catch_unwind::hd61d56eddbf98268
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/panic.rs:394
  99:           0xdbe832 - std::thread::Builder::spawn_unchecked::{{closure}}::h6b8013461217867c
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libstd/thread/mod.rs:469
  100:           0xdbebd4 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h5abf8bbc2752c5c2
                               at /rustc/760226733e940cb375f791e894fbb554555eeb01/src/libcore/ops/function.rs:235
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic in Arbiter thread, shutting down system.

I also tested it in VMs (parallels and VirtualBox) on Linux and Mac hosts. It always results in this exact failure.

The command was curl --http1.1 -v -k http://localhost:8080. Port 8080 is the exposed reverse proxy. It turns out that enabling TLS makes a big difference in the web server and it doesn't crash at all if the reverse proxy connects to the web server via plain HTTP.

curl reverse proxy web server TLS enabled crashes
on host on host on host yes no
on host on host on host no no
on host in Docker on host yes yes
on host in Docker on host no no
on host in VM on host yes yes
on host in VM on host no no

Having just the web server run in Docker is just fine, whether TLS is enabled or not. The command used was just curl --http1.1 localhost:8080 where 8080 is the port exposed by Docker for the web server.

curl web server TLS enabled crashes
on host on host yes no
on host in Docker yes no
on host on host no no
on host in Docker no no

So it only crashes if connecting to a TLS web server on the host through a virtual interface. I don't really know what to make of this.

The reverse proxy is here: https://github.com/svenstaro/proxyboi/ and the relevant code is around htis part: https://github.com/svenstaro/proxyboi/blob/3c58ace975a06f13b3e4e34b0724161dc3b401b3/src/main.rs#L103
It's very similar to the actix-web reverse proxy example but with added stuff for allowing invalid TLS certificates.

I'll try to create a minimal code example. However, maybe the info supplied is already useful to somebody somehow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.