1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 16:50:37 +02:00

fix disconnect callback

This commit is contained in:
Nikolay Kim
2019-07-03 13:02:03 +06:00
parent 922a919572
commit da302d4b7a
4 changed files with 79 additions and 11 deletions

View File

@ -314,7 +314,10 @@ where
self.disconnect(true);
Err(err)
}
FramedState::Stopping => Ok(Async::Ready(())),
FramedState::Stopping => {
self.disconnect(false);
Ok(Async::Ready(()))
}
}
}
}

View File

@ -3,7 +3,7 @@ use std::rc::Rc;
use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder};
use actix_service::{IntoNewService, IntoService, NewService, Service};
use futures::{Async, Future, IntoFuture, Poll};
use futures::{Async, Future, Poll};
use crate::connect::{Connect, ConnectResult};
use crate::dispatcher::FramedDispatcher;
@ -139,11 +139,11 @@ where
self
}
pub fn finish<F, T>(
pub fn finish<F, T, Cfg>(
self,
service: F,
) -> impl NewService<
Config = (),
Config = Cfg,
Request = Io,
Response = (),
Error = ServiceError<C::Error, Codec>,
@ -167,14 +167,14 @@ where
}
}
pub(crate) struct FramedService<St, C, T, Io, Codec> {
pub(crate) struct FramedService<St, C, T, Io, Codec, Cfg> {
connect: C,
handler: Rc<T>,
disconnect: Option<Rc<Fn(&mut St, bool)>>,
_t: PhantomData<(St, Io, Codec)>,
_t: PhantomData<(St, Io, Codec, Cfg)>,
}
impl<St, C, T, Io, Codec> NewService for FramedService<St, C, T, Io, Codec>
impl<St, C, T, Io, Codec, Cfg> NewService for FramedService<St, C, T, Io, Codec, Cfg>
where
St: 'static,
Io: AsyncRead + AsyncWrite,
@ -192,7 +192,7 @@ where
<Codec as Encoder>::Item: 'static,
<Codec as Encoder>::Error: std::fmt::Debug,
{
type Config = ();
type Config = Cfg;
type Request = Io;
type Response = ();
type Error = ServiceError<C::Error, Codec>;
@ -200,7 +200,7 @@ where
type Service = FramedServiceImpl<St, C::Service, T, Io, Codec>;
type Future = Box<Future<Item = Self::Service, Error = Self::InitError>>;
fn new_service(&self, _: &()) -> Self::Future {
fn new_service(&self, _: &Cfg) -> Self::Future {
let handler = self.handler.clone();
let disconnect = self.disconnect.clone();