mirror of
https://github.com/actix/actix-web.git
synced 2025-02-28 00:27:15 +00:00
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> |
||
---|---|---|
.. | ||
client.rs | ||
codec.rs | ||
decoder.rs | ||
dispatcher.rs | ||
encoder.rs | ||
expect.rs | ||
mod.rs | ||
payload.rs | ||
service.rs | ||
upgrade.rs | ||
utils.rs |