mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
disable shutdown atm
This commit is contained in:
parent
93b1c5fd46
commit
c3ad516f56
@ -49,8 +49,8 @@ where
|
|||||||
T: IoStream,
|
T: IoStream,
|
||||||
H: HttpHandler + 'static,
|
H: HttpHandler + 'static,
|
||||||
{
|
{
|
||||||
node: Node<HttpProtocol<T, H>>,
|
proto: HttpProtocol<T, H>,
|
||||||
node_reg: bool,
|
node: Option<Node<()>>,
|
||||||
ka_timeout: Option<Delay>,
|
ka_timeout: Option<Delay>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,12 +64,8 @@ where
|
|||||||
|
|
||||||
HttpChannel {
|
HttpChannel {
|
||||||
ka_timeout,
|
ka_timeout,
|
||||||
node_reg: false,
|
node: None,
|
||||||
node: Node::new(HttpProtocol::Unknown(
|
proto: HttpProtocol::Unknown(settings, io, BytesMut::with_capacity(8192)),
|
||||||
settings,
|
|
||||||
io,
|
|
||||||
BytesMut::with_capacity(8192),
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +76,9 @@ where
|
|||||||
H: HttpHandler + 'static,
|
H: HttpHandler + 'static,
|
||||||
{
|
{
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.node.remove();
|
if let Some(mut node) = self.node.take() {
|
||||||
|
node.remove()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +96,9 @@ where
|
|||||||
match self.ka_timeout.as_mut().unwrap().poll() {
|
match self.ka_timeout.as_mut().unwrap().poll() {
|
||||||
Ok(Async::Ready(_)) => {
|
Ok(Async::Ready(_)) => {
|
||||||
trace!("Slow request timed out, close connection");
|
trace!("Slow request timed out, close connection");
|
||||||
let proto = mem::replace(self.node.get_mut(), HttpProtocol::None);
|
let proto = mem::replace(&mut self.proto, HttpProtocol::None);
|
||||||
if let HttpProtocol::Unknown(settings, io, buf) = proto {
|
if let HttpProtocol::Unknown(settings, io, buf) = proto {
|
||||||
*self.node.get_mut() =
|
self.proto = HttpProtocol::H1(h1::Http1Dispatcher::for_error(
|
||||||
HttpProtocol::H1(h1::Http1Dispatcher::for_error(
|
|
||||||
settings,
|
settings,
|
||||||
io,
|
io,
|
||||||
StatusCode::REQUEST_TIMEOUT,
|
StatusCode::REQUEST_TIMEOUT,
|
||||||
@ -117,19 +114,24 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.node_reg {
|
if self.node.is_none() {
|
||||||
self.node_reg = true;
|
self.node = Some(Node::new(()));
|
||||||
let settings = match self.node.get_mut() {
|
let _ = match self.proto {
|
||||||
HttpProtocol::H1(ref mut h1) => h1.settings().clone(),
|
HttpProtocol::H1(ref mut h1) => {
|
||||||
HttpProtocol::H2(ref mut h2) => h2.settings().clone(),
|
self.node.as_mut().map(|n| h1.settings().head().insert(n))
|
||||||
HttpProtocol::Unknown(ref mut settings, _, _) => settings.clone(),
|
}
|
||||||
|
HttpProtocol::H2(ref mut h2) => {
|
||||||
|
self.node.as_mut().map(|n| h2.settings().head().insert(n))
|
||||||
|
}
|
||||||
|
HttpProtocol::Unknown(ref mut settings, _, _) => {
|
||||||
|
self.node.as_mut().map(|n| settings.head().insert(n))
|
||||||
|
}
|
||||||
HttpProtocol::None => unreachable!(),
|
HttpProtocol::None => unreachable!(),
|
||||||
};
|
};
|
||||||
settings.head().insert(&mut self.node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut is_eof = false;
|
let mut is_eof = false;
|
||||||
let kind = match self.node.get_mut() {
|
let kind = match self.proto {
|
||||||
HttpProtocol::H1(ref mut h1) => return h1.poll(),
|
HttpProtocol::H1(ref mut h1) => return h1.poll(),
|
||||||
HttpProtocol::H2(ref mut h2) => return h2.poll(),
|
HttpProtocol::H2(ref mut h2) => return h2.poll(),
|
||||||
HttpProtocol::Unknown(_, ref mut io, ref mut buf) => {
|
HttpProtocol::Unknown(_, ref mut io, ref mut buf) => {
|
||||||
@ -169,11 +171,11 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
// upgrade to specific http protocol
|
// upgrade to specific http protocol
|
||||||
let proto = mem::replace(self.node.get_mut(), HttpProtocol::None);
|
let proto = mem::replace(&mut self.proto, HttpProtocol::None);
|
||||||
if let HttpProtocol::Unknown(settings, io, buf) = proto {
|
if let HttpProtocol::Unknown(settings, io, buf) = proto {
|
||||||
match kind {
|
match kind {
|
||||||
ProtocolKind::Http1 => {
|
ProtocolKind::Http1 => {
|
||||||
*self.node.get_mut() = HttpProtocol::H1(h1::Http1Dispatcher::new(
|
self.proto = HttpProtocol::H1(h1::Http1Dispatcher::new(
|
||||||
settings,
|
settings,
|
||||||
io,
|
io,
|
||||||
buf,
|
buf,
|
||||||
@ -183,7 +185,7 @@ where
|
|||||||
return self.poll();
|
return self.poll();
|
||||||
}
|
}
|
||||||
ProtocolKind::Http2 => {
|
ProtocolKind::Http2 => {
|
||||||
*self.node.get_mut() = HttpProtocol::H2(h2::Http2::new(
|
self.proto = HttpProtocol::H2(h2::Http2::new(
|
||||||
settings,
|
settings,
|
||||||
io,
|
io,
|
||||||
buf.freeze(),
|
buf.freeze(),
|
||||||
@ -203,8 +205,8 @@ where
|
|||||||
T: IoStream,
|
T: IoStream,
|
||||||
H: HttpHandler + 'static,
|
H: HttpHandler + 'static,
|
||||||
{
|
{
|
||||||
node: Node<HttpProtocol<T, H>>,
|
proto: HttpProtocol<T, H>,
|
||||||
node_reg: bool,
|
node: Option<Node<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, H> H1Channel<T, H>
|
impl<T, H> H1Channel<T, H>
|
||||||
@ -214,14 +216,14 @@ where
|
|||||||
{
|
{
|
||||||
pub(crate) fn new(settings: ServiceConfig<H>, io: T) -> H1Channel<T, H> {
|
pub(crate) fn new(settings: ServiceConfig<H>, io: T) -> H1Channel<T, H> {
|
||||||
H1Channel {
|
H1Channel {
|
||||||
node_reg: false,
|
node: None,
|
||||||
node: Node::new(HttpProtocol::H1(h1::Http1Dispatcher::new(
|
proto: HttpProtocol::H1(h1::Http1Dispatcher::new(
|
||||||
settings,
|
settings,
|
||||||
io,
|
io,
|
||||||
BytesMut::with_capacity(8192),
|
BytesMut::with_capacity(8192),
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
))),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +234,9 @@ where
|
|||||||
H: HttpHandler + 'static,
|
H: HttpHandler + 'static,
|
||||||
{
|
{
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.node.remove();
|
if let Some(mut node) = self.node.take() {
|
||||||
|
node.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,16 +249,17 @@ where
|
|||||||
type Error = HttpDispatchError;
|
type Error = HttpDispatchError;
|
||||||
|
|
||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||||
if !self.node_reg {
|
if self.node.is_none() {
|
||||||
self.node_reg = true;
|
self.node = Some(Node::new(()));
|
||||||
let settings = match self.node.get_mut() {
|
match self.proto {
|
||||||
HttpProtocol::H1(ref mut h1) => h1.settings().clone(),
|
HttpProtocol::H1(ref mut h1) => {
|
||||||
|
self.node.as_mut().map(|n| h1.settings().head().insert(n));
|
||||||
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
settings.head().insert(&mut self.node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.node.get_mut() {
|
match self.proto {
|
||||||
HttpProtocol::H1(ref mut h1) => h1.poll(),
|
HttpProtocol::H1(ref mut h1) => h1.poll(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
@ -276,10 +281,6 @@ impl<T> Node<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mut(&mut self) -> &mut T {
|
|
||||||
&mut self.element
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert<I>(&mut self, next_el: &mut Node<I>) {
|
fn insert<I>(&mut self, next_el: &mut Node<I>) {
|
||||||
let next: *mut Node<T> = next_el as *const _ as *mut _;
|
let next: *mut Node<T> = next_el as *const _ as *mut _;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user