fix windows cfg

This commit is contained in:
fakeshadow 2021-04-21 19:36:01 +08:00
parent 0a1671387c
commit 9c7cbd2551
3 changed files with 17 additions and 26 deletions

View File

@ -190,10 +190,7 @@ impl Future for Accept {
this.avail.set_available(handle.idx(), true);
this.handles.push(handle);
}
Interest::Pause => {
this.paused = true;
break;
}
Interest::Pause => this.paused = true,
Interest::Resume => this.paused = false,
Interest::Stop => return Poll::Ready(()),
}

View File

@ -5,7 +5,6 @@ use std::task::{Context, Poll};
use actix_service::{Service, ServiceFactory as BaseServiceFactory};
use actix_utils::future::{ready, Ready};
use futures_core::future::LocalBoxFuture;
use log::error;
use crate::socket::{FromStream, Stream};
use crate::worker::WorkerCounterGuard;
@ -63,20 +62,15 @@ where
}
fn call(&self, (guard, req): (WorkerCounterGuard, Stream)) -> Self::Future {
ready(match FromStream::from_mio(req) {
Ok(stream) => {
let stream = FromStream::from_stream(req);
let f = self.service.call(stream);
actix_rt::spawn(async move {
let _ = f.await;
drop(guard);
});
Ok(())
}
Err(e) => {
error!("Can not convert to an async tcp stream: {}", e);
Err(())
}
})
ready(Ok(()))
}
}

View File

@ -80,7 +80,7 @@ pub enum Stream {
/// helper trait for converting mio stream to tokio stream.
pub trait FromStream: Sized {
fn from_mio(stream: Stream) -> io::Result<Self>;
fn from_stream(stream: Stream) -> Self;
}
#[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
impl FromStream for TcpStream {
fn from_mio(stream: MioStream) -> io::Result<Self> {
fn from_stream(stream: Stream) -> Self {
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
impl FromStream for TcpStream {
fn from_mio(stream: Stream) -> io::Result<Self> {
fn from_stream(stream: Stream) -> Self {
match stream {
Stream::Tcp(stream) => Ok(stream),
Stream::Tcp(stream) => stream,
Stream::Uds(_) => {
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
impl FromStream for actix_rt::net::UnixStream {
fn from_mio(stream: Stream) -> io::Result<Self> {
fn from_stream(stream: Stream) -> Self {
match stream {
Stream::Tcp(_) => panic!("Should not happen, bug in server impl"),
Stream::Uds(stream) => Ok(stream),
Stream::Uds(stream) => stream,
}
}
}