mirror of https://github.com/fafhrd91/actix-web
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 | ||
| cookie | ||
| encoding | ||
| h1 | ||
| h2 | ||
| header | ||
| ws | ||
| body.rs | ||
| builder.rs | ||
| cloneable.rs | ||
| config.rs | ||
| error.rs | ||
| extensions.rs | ||
| helpers.rs | ||
| httpcodes.rs | ||
| httpmessage.rs | ||
| lib.rs | ||
| macros.rs | ||
| message.rs | ||
| payload.rs | ||
| request.rs | ||
| response.rs | ||
| service.rs | ||
| test.rs | ||
| time_parser.rs | ||