diff --git a/src/server/worker.rs b/src/server/worker.rs index 1ca42ccc3..d9cca29f6 100644 --- a/src/server/worker.rs +++ b/src/server/worker.rs @@ -192,7 +192,7 @@ impl StreamHandlerType { let io = TcpStream::from_std(io, &Handle::default()) .expect("failed to associate TCP stream"); - Arbiter::spawn(TlsAcceptorExt::accept_async(acceptor, io).then( + current_thread::spawn(TlsAcceptorExt::accept_async(acceptor, io).then( move |res| { match res { Ok(io) => current_thread::spawn(HttpChannel::new( @@ -213,7 +213,7 @@ impl StreamHandlerType { let io = TcpStream::from_std(io, &Handle::default()) .expect("failed to associate TCP stream"); - Arbiter::spawn(SslAcceptorExt::accept_async(acceptor, io).then( + current_thread::spawn(SslAcceptorExt::accept_async(acceptor, io).then( move |res| { match res { Ok(io) => { diff --git a/src/test.rs b/src/test.rs index 89fa632e1..28403625b 100644 --- a/src/test.rs +++ b/src/test.rs @@ -14,7 +14,7 @@ use net2::TcpBuilder; use tokio::runtime::current_thread::Runtime; #[cfg(feature = "alpn")] -use openssl::ssl::SslAcceptor; +use openssl::ssl::SslAcceptorBuilder; use application::{App, HttpApplication}; use body::Binary; @@ -251,7 +251,7 @@ impl Drop for TestServer { pub struct TestServerBuilder { state: Box S + Sync + Send + 'static>, #[cfg(feature = "alpn")] - ssl: Option, + ssl: Option, } impl TestServerBuilder { @@ -268,7 +268,7 @@ impl TestServerBuilder { #[cfg(feature = "alpn")] /// Create ssl server - pub fn ssl(mut self, ssl: SslAcceptor) -> Self { + pub fn ssl(mut self, ssl: SslAcceptorBuilder) -> Self { self.ssl = Some(ssl); self } @@ -291,10 +291,9 @@ impl TestServerBuilder { let tcp = net::TcpListener::bind("127.0.0.1:0").unwrap(); let local_addr = tcp.local_addr().unwrap(); - let state = self.state; - System::new("actix-test-server") .config(move || { + let state = self.state; let srv = HttpServer::new(move || { let mut app = TestApp::new(state()); config(&mut app); @@ -311,22 +310,11 @@ impl TestServerBuilder { #[cfg(feature = "alpn")] { - use futures::Stream; - use std::io; - use tokio_openssl::SslAcceptorExt; - let ssl = self.ssl.take(); if let Some(ssl) = ssl { - srv.start_incoming( - tcp.incoming().and_then(move |sock| { - ssl.accept_async(sock).map_err(|e| { - io::Error::new(io::ErrorKind::Other, e) - }) - }), - false, - ); + srv.listen_ssl(tcp, ssl).unwrap().start(); } else { - srv.start_incoming(tcp.incoming(), false); + srv.listen(tcp).start(); } } #[cfg(not(feature = "alpn"))] diff --git a/tests/test_ws.rs b/tests/test_ws.rs index 4f9565ddc..dd65d4a58 100644 --- a/tests/test_ws.rs +++ b/tests/test_ws.rs @@ -227,7 +227,7 @@ fn test_ws_server_ssl() { .set_certificate_chain_file("tests/cert.pem") .unwrap(); - let mut srv = test::TestServer::build().ssl(builder.build()).start(|app| { + let mut srv = test::TestServer::build().ssl(builder).start(|app| { app.handler(|req| { ws::start( req,