1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-02-28 00:27:15 +00:00
actix-web/actix-http/src/h1
Aaron Hill 71c4bd1b30
Remove uses of Pin::new_unchecked in h1 Dispatcher (#1374)
This removes the last uses of unsafe `Pin` functions in actix-web.

This PR adds a `Pin<Box<_>>` wrapper to `DispatcherState::Upgrade`,
`State::ExpectCall`, and `State::ServiceCall`.

The previous uses of the futures `State::ExpectCall` and `State::ServiceCall`
were Undefined Behavior - a future was obtained from `self.expect.call`
or `self.service.call`, pinned on the stack, and then immediately
returned from `handle_request`. The only alternative to using `Box::pin`
would be to refactor `handle_request` to write the futures directly into
their final location, or avoid polling them before they are returned.

The previous use of `DispatcherState::Upgrade` doesn't seem to be
unsound. However, having data pinned inside an enum that we
`std::mem::replace` would require some careful `unsafe` code to ensure
that we never call `std::mem::replace` when the active variant contains
pinned data. By using `Box::pin`, we any possibility of future
refactoring accidentally introducing undefined behavior.

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-02-26 08:21:05 +09:00
..
client.rs fix warnings 2019-12-13 10:59:02 +06:00
codec.rs cleanup imports 2019-12-13 11:24:57 +06:00
decoder.rs Use .advance() intead of .split_to() 2019-12-19 09:56:14 +06:00
dispatcher.rs Remove uses of Pin::new_unchecked in h1 Dispatcher (#1374) 2020-02-26 08:21:05 +09:00
encoder.rs cleanup imports 2019-12-13 11:24:57 +06:00
expect.rs cleanup imports 2019-12-13 11:24:57 +06:00
mod.rs add h1::SendResponse future; renamed to MessageBody::size 2019-04-10 12:24:17 -07:00
payload.rs cleanup imports 2019-12-13 11:24:57 +06:00
service.rs add extra constraints 2020-01-10 11:36:59 +06:00
upgrade.rs cleanup imports 2019-12-13 11:24:57 +06:00
utils.rs clippy warnings 2019-12-08 00:46:51 +06:00