Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(http/retry): document ReplayBody::poll_*() panics #3582

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

cratelyn
Copy link
Collaborator

a ReplayBody<B> demands a particular contract of its users: one must not poll two bodies in parallel. this is currently mentioned as an implicit assumption on an internal helper function, acquire_state<'a>, here:

https://github.com/linkerd/linkerd2-proxy/blob/main/linkerd/http/retry/src/replay.rs#L127-L131

    /// # Panics
    ///
    /// This panics if another clone has currently acquired the state, based on
    /// the assumption that a retry body will not be polled until the previous
    /// request has been dropped.
    fn acquire_state<'a>(
        state: &'a mut Option<BodyState<B>>,
        shared: &Mutex<Option<BodyState<B>>>,
    ) -> &'a mut BodyState<B> {
        state.get_or_insert_with(|| shared.lock().take().expect("missing body state"))
    }

this commit echoes this sentiment on the relevant public-facing parts of this middleware: its Body trait methods.

@cratelyn cratelyn marked this pull request as ready for review January 30, 2025 18:45
@cratelyn cratelyn requested a review from a team as a code owner January 30, 2025 18:45
@cratelyn cratelyn merged commit 8d37620 into main Jan 30, 2025
15 checks passed
@cratelyn cratelyn deleted the kate/http-retry.document-replay-poll-panics branch January 30, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants