Skip to content

Drain readable PROXY protocol bytes before handling a client half-close #1823

Closed

Description

@FlorentinDUBOIS

On Linux, final request bytes and EPOLLRDHUP can arrive as one READABLE|HUP event after the client calls shutdown(SHUT_WR). TcpSession::ready_inner handles frontend HUP before readable data (ordering); front_hup closes every pre-pipe state other than SNI preread (handler). ExpectProxyProtocol::readable would parse the complete header and upgrade the session (parser), but it never runs.

The retained Linux regression queues a complete PROXY-v2 header plus payload, half-closes the client write side, observes the real epoll READABLE|HUP event, and expects the backend to receive the payload and the client to receive the response:

mise exec [email protected] -- cargo test -p sozu-lib expect_proxy_half_close_drains_payload_and_returns_response -j4 -- --nocapture

It fails before backend dial because the session closes. The reported panic is the test assertion; no Sōzu server panic was observed.

Acceptance: when readable bytes and a read-half close are coalesced, drain/parse the readable direction before final close handling, preserve the response half while work remains, and retain coverage for zero-byte bare PROXY health checks.

Evidence scope: runtime checks used 8ed38435c6e80dc374de421116d8b145f1e5ce6a; the relevant production paths were independently checked at bd19a78e2831fa9b3bc099eff96359f1bd457958 on 2026-10-03. This issue tracks lifecycle behavior and regression coverage.

Activity

  1. FlorentinDUBOIS commented on Oct 3, 2026

    @FlorentinDUBOIS
    CollaboratorAuthor

    #1836 fixes the PROXY-v2 header being dropped when its bytes and the client's half-close arrive in one READABLE | HUP event, for both TCP and the HTTP/HTTPS expect stage. It does not deliver the backend response after the half-close: the TCP pipe closes once the request is flushed (Pipe::check_connections, lib/src/protocol/pipe.rs), for every TCP session, PROXY protocol or not. That policy question is tracked in #1840.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions