Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(http/upgrade): `Http11Upgrade::insert_half` matches on `self` this is a noöp change, to set the stage for subsequent changes to the internal model of `Http11Upgrade`. this `inner` field will shortly be an option, and this will make it easier to only follow these panicking branches when the inner lock is `Some(_)`. Signed-off-by: katelyn martin <[email protected]> * refactor(http/upgrade): `Http11Upgade` stores an `Option<T>` this commit hinges on this change to the upgrade middleware's `inner` field. we still retain a reference-counted copy of the `Inner` state, but now we may store `None` here. ``` pub struct Http11Upgrade { half: Half, - inner: Arc<Inner>, + inner: Option<Arc<Inner>>, } ``` a new branch is added to the `insert_half` method that consumes the "sender" and inserts an upgrade future; when this is `None` it will do nothing, rather than panicking. Signed-off-by: katelyn martin <[email protected]> * refactor(http/upgrade): `Half` marker is `Copy` this type is an empty flag to indicate whether an `Http11Upgrade` extension corresponds to the server or client half of the upgrade future channel. this type is made copy, to facilitate making the `Http11Upgrade` extension safely cloneable. Signed-off-by: katelyn martin <[email protected]> * refactor(http/upgrade): `Http11Upgrade` is `Clone` this commit makes `Http11Upgrade` a cloneable type. see <linkerd/linkerd2#8733>. in the 1.0 interface of the `http` crate, request and response extensions must now satisfy a `Clone` bound. `Http11Upgrade` was written before this was the case, and is very intentionally designed around the idea that it *not* be cloneable. `insert_half()` in particular could cause the proxy to panic if it were to clone a request or response's extensions. it might call `insert_half()` a second time, and discover that the `TryLock<T>` had already been set. moreover, holding on to a copy of the extensions would prevent the `Drop` method for `Inner` from being called. This would cause connections that negotiate an HTTP/1.1 upgrade to deadlock due to the `OnUpgrade` futures never being polled, and failing to create a `Duplex` that acts as the connection's I/O transport. this commit makes use of the alterations to `Http11Upgrade` made in previous commits, and adds a *safe* implementation of `Clone`. by only shallowly copying the extension, we tie the upgrade glue to a *specific* request/response. the extension can be cloned, but any generated copies will be inert. Signed-off-by: katelyn martin <[email protected]> * chore(http/upgrade): fix broken intradoc links Signed-off-by: katelyn martin <[email protected]> * chore(http/upgrade): add `thiserror` dependency Signed-off-by: katelyn martin <[email protected]> * refactor(proxy/http): use `.await` syntax `FutureExt::map_ok()` won't work if we try to return an error from this block. the `and_then()` adaptor is used to chain futures, and also won't work given a synchronous closure. this can be done with the equivalent `.await` syntax, and leaves a nicer hole for us to propagate other errors here, shortly. Signed-off-by: katelyn martin <[email protected]> * review(http/upgrade): propagate `insert_half()` failures #3540 (comment) Signed-off-by: katelyn martin <[email protected]> Co-Authored-By: Oliver Gould <[email protected]> * docs(http/upgrade): tweak comment Signed-off-by: katelyn martin <[email protected]> --------- Signed-off-by: katelyn martin <[email protected]> Co-authored-by: Oliver Gould <[email protected]>
- Loading branch information