mirror of https://github.com/fafhrd91/actix-net
fix windows cfg
This commit is contained in:
parent
0a1671387c
commit
9c7cbd2551
|
@ -190,10 +190,7 @@ impl Future for Accept {
|
||||||
this.avail.set_available(handle.idx(), true);
|
this.avail.set_available(handle.idx(), true);
|
||||||
this.handles.push(handle);
|
this.handles.push(handle);
|
||||||
}
|
}
|
||||||
Interest::Pause => {
|
Interest::Pause => this.paused = true,
|
||||||
this.paused = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Interest::Resume => this.paused = false,
|
Interest::Resume => this.paused = false,
|
||||||
Interest::Stop => return Poll::Ready(()),
|
Interest::Stop => return Poll::Ready(()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ use std::task::{Context, Poll};
|
||||||
use actix_service::{Service, ServiceFactory as BaseServiceFactory};
|
use actix_service::{Service, ServiceFactory as BaseServiceFactory};
|
||||||
use actix_utils::future::{ready, Ready};
|
use actix_utils::future::{ready, Ready};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use log::error;
|
|
||||||
|
|
||||||
use crate::socket::{FromStream, Stream};
|
use crate::socket::{FromStream, Stream};
|
||||||
use crate::worker::WorkerCounterGuard;
|
use crate::worker::WorkerCounterGuard;
|
||||||
|
@ -63,20 +62,15 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&self, (guard, req): (WorkerCounterGuard, Stream)) -> Self::Future {
|
fn call(&self, (guard, req): (WorkerCounterGuard, Stream)) -> Self::Future {
|
||||||
ready(match FromStream::from_mio(req) {
|
let stream = FromStream::from_stream(req);
|
||||||
Ok(stream) => {
|
|
||||||
let f = self.service.call(stream);
|
let f = self.service.call(stream);
|
||||||
actix_rt::spawn(async move {
|
actix_rt::spawn(async move {
|
||||||
let _ = f.await;
|
let _ = f.await;
|
||||||
drop(guard);
|
drop(guard);
|
||||||
});
|
});
|
||||||
Ok(())
|
|
||||||
}
|
ready(Ok(()))
|
||||||
Err(e) => {
|
|
||||||
error!("Can not convert to an async tcp stream: {}", e);
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub enum Stream {
|
||||||
|
|
||||||
/// helper trait for converting mio stream to tokio stream.
|
/// helper trait for converting mio stream to tokio stream.
|
||||||
pub trait FromStream: Sized {
|
pub trait FromStream: Sized {
|
||||||
fn from_mio(stream: Stream) -> io::Result<Self>;
|
fn from_stream(stream: Stream) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
@ -91,9 +91,9 @@ mod win_impl {
|
||||||
|
|
||||||
// FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream
|
// FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream
|
||||||
impl FromStream for TcpStream {
|
impl FromStream for TcpStream {
|
||||||
fn from_mio(stream: MioStream) -> io::Result<Self> {
|
fn from_stream(stream: Stream) -> Self {
|
||||||
match stream {
|
match stream {
|
||||||
MioStream::Tcp(stream) => Ok(stream),
|
MioStream::Tcp(stream) => stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,9 +105,9 @@ mod unix_impl {
|
||||||
|
|
||||||
// FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream
|
// FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream
|
||||||
impl FromStream for TcpStream {
|
impl FromStream for TcpStream {
|
||||||
fn from_mio(stream: Stream) -> io::Result<Self> {
|
fn from_stream(stream: Stream) -> Self {
|
||||||
match stream {
|
match stream {
|
||||||
Stream::Tcp(stream) => Ok(stream),
|
Stream::Tcp(stream) => stream,
|
||||||
Stream::Uds(_) => {
|
Stream::Uds(_) => {
|
||||||
panic!("Should not happen, bug in server impl");
|
panic!("Should not happen, bug in server impl");
|
||||||
}
|
}
|
||||||
|
@ -117,10 +117,10 @@ mod unix_impl {
|
||||||
|
|
||||||
// FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream
|
// FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream
|
||||||
impl FromStream for actix_rt::net::UnixStream {
|
impl FromStream for actix_rt::net::UnixStream {
|
||||||
fn from_mio(stream: Stream) -> io::Result<Self> {
|
fn from_stream(stream: Stream) -> Self {
|
||||||
match stream {
|
match stream {
|
||||||
Stream::Tcp(_) => panic!("Should not happen, bug in server impl"),
|
Stream::Tcp(_) => panic!("Should not happen, bug in server impl"),
|
||||||
Stream::Uds(stream) => Ok(stream),
|
Stream::Uds(stream) => stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue