mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
Re-apply commit 2cf7b3ad20
This ended up getting reverted by #1367, which re-introduced an unsound use of `Pin::new_unchecked` See my original PR #1374 for the reasoning behind this change.
This commit is contained in:
parent
c8f0672ef7
commit
e90950fee1
@ -73,7 +73,7 @@ where
|
|||||||
U::Error: fmt::Display,
|
U::Error: fmt::Display,
|
||||||
{
|
{
|
||||||
Normal(#[pin] InnerDispatcher<T, S, B, X, U>),
|
Normal(#[pin] InnerDispatcher<T, S, B, X, U>),
|
||||||
Upgrade(#[pin] U::Future),
|
Upgrade(Pin<Box<U::Future>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project]
|
#[pin_project]
|
||||||
@ -123,8 +123,8 @@ where
|
|||||||
B: MessageBody,
|
B: MessageBody,
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
ExpectCall(#[pin] X::Future),
|
ExpectCall(Pin<Box<X::Future>>),
|
||||||
ServiceCall(#[pin] S::Future),
|
ServiceCall(Pin<Box<S::Future>>),
|
||||||
SendPayload(#[pin] ResponseBody<B>),
|
SendPayload(#[pin] ResponseBody<B>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,11 +391,11 @@ where
|
|||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
},
|
},
|
||||||
State::ExpectCall(fut) => match fut.poll(cx) {
|
State::ExpectCall(fut) => match fut.as_mut().poll(cx) {
|
||||||
Poll::Ready(Ok(req)) => {
|
Poll::Ready(Ok(req)) => {
|
||||||
self.as_mut().send_continue();
|
self.as_mut().send_continue();
|
||||||
this = self.as_mut().project();
|
this = self.as_mut().project();
|
||||||
this.state.set(State::ServiceCall(this.service.call(req)));
|
this.state.set(State::ServiceCall(Box::pin(this.service.call(req))));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Poll::Ready(Err(e)) => {
|
Poll::Ready(Err(e)) => {
|
||||||
@ -405,7 +405,7 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => None,
|
Poll::Pending => None,
|
||||||
},
|
},
|
||||||
State::ServiceCall(fut) => match fut.poll(cx) {
|
State::ServiceCall(fut) => match fut.as_mut().poll(cx) {
|
||||||
Poll::Ready(Ok(res)) => {
|
Poll::Ready(Ok(res)) => {
|
||||||
let (res, body) = res.into().replace_body(());
|
let (res, body) = res.into().replace_body(());
|
||||||
let state = self.as_mut().send_response(res, body)?;
|
let state = self.as_mut().send_response(res, body)?;
|
||||||
@ -485,8 +485,8 @@ where
|
|||||||
) -> Result<State<S, B, X>, DispatchError> {
|
) -> Result<State<S, B, X>, DispatchError> {
|
||||||
// Handle `EXPECT: 100-Continue` header
|
// Handle `EXPECT: 100-Continue` header
|
||||||
let req = if req.head().expect() {
|
let req = if req.head().expect() {
|
||||||
let mut task = self.as_mut().project().expect.call(req);
|
let mut task = Box::pin(self.as_mut().project().expect.call(req));
|
||||||
match unsafe { Pin::new_unchecked(&mut task) }.poll(cx) {
|
match task.as_mut().poll(cx) {
|
||||||
Poll::Ready(Ok(req)) => {
|
Poll::Ready(Ok(req)) => {
|
||||||
self.as_mut().send_continue();
|
self.as_mut().send_continue();
|
||||||
req
|
req
|
||||||
@ -504,8 +504,8 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Call service
|
// Call service
|
||||||
let mut task = self.as_mut().project().service.call(req);
|
let mut task = Box::pin(self.as_mut().project().service.call(req));
|
||||||
match unsafe { Pin::new_unchecked(&mut task) }.poll(cx) {
|
match task.as_mut().poll(cx) {
|
||||||
Poll::Ready(Ok(res)) => {
|
Poll::Ready(Ok(res)) => {
|
||||||
let (res, body) = res.into().replace_body(());
|
let (res, body) = res.into().replace_body(());
|
||||||
self.send_response(res, body)
|
self.send_response(res, body)
|
||||||
@ -807,7 +807,7 @@ where
|
|||||||
self.as_mut()
|
self.as_mut()
|
||||||
.project()
|
.project()
|
||||||
.inner
|
.inner
|
||||||
.set(DispatcherState::Upgrade(upgrade));
|
.set(DispatcherState::Upgrade(Box::pin(upgrade)));
|
||||||
return self.poll(cx);
|
return self.poll(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,7 +855,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DispatcherState::Upgrade(fut) => fut.poll(cx).map_err(|e| {
|
DispatcherState::Upgrade(fut) => fut.as_mut().poll(cx).map_err(|e| {
|
||||||
error!("Upgrade handler error: {}", e);
|
error!("Upgrade handler error: {}", e);
|
||||||
DispatchError::Upgrade
|
DispatchError::Upgrade
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user