Skip to content

Dispatch WRITE_COMPLETE when TLS handshake completes#11574

Merged
bneradt merged 1 commit intoapache:masterfrom
bneradt:fix_proxy_protocol_over_tls_hangs
Jul 19, 2024
Merged

Dispatch WRITE_COMPLETE when TLS handshake completes#11574
bneradt merged 1 commit intoapache:masterfrom
bneradt:fix_proxy_protocol_over_tls_hangs

Conversation

@bneradt
Copy link
Copy Markdown
Contributor

@bneradt bneradt commented Jul 18, 2024

The SSLNetVConnection.cc logic already does this, so this is a port over
of that event dispatch functionality when ntodo is 0 for
UnixNetVConnection.cc. @JosiahWI and I investigated a periodic failure
in proxy_protocol.test.py and we noticed that the issue was due to the
handshake completing within a single call of sslStartHandshake. In those
cases, the ConnectingEntry handler wasn't called back and the connection
would hang without progressing with the rest of the request after the
handshake completed. This ensures that the ConnectingEntry handler is
called in these circumstances.


Review Comments

SSLNetVConnection Reference

For reference, here is the corresponding dispatch from SSLNetVConnection that does this callback as well:

// If this was driven by a zero length read, signal complete when
// the handshake is complete. Otherwise set up for continuing read
// operations.
if (ntodo <= 0) {
readSignalDone(VC_EVENT_READ_COMPLETE, nh);

This patch simply pulls in that callback for UnixNetVConnection's TLS handshake handling logic.

Testing

The proxy_protocol.test.py test demonstrates this infrequently in ASF CI. I have never seen this locally on my mac. I've run this test in CI using my access to the CI vms dozens of times and have not seen a failure. I have been able to reproduce the error fairly consistently before this patch, so I feel this addresses the issue well.

@bneradt bneradt added the TLS label Jul 18, 2024
@bneradt bneradt added this to the 10.1.0 milestone Jul 18, 2024
@bneradt bneradt self-assigned this Jul 18, 2024
@JosiahWI
Copy link
Copy Markdown
Contributor

Fixes #11552.

@JosiahWI JosiahWI linked an issue Jul 18, 2024 that may be closed by this pull request
The SSLNetVConnection.cc logic already does this, so this is a port over
of that event dispatch functionality when ntodo is 0 for
UnixNetVConnection.cc. @JosiahWI and I investigated a periodic failure
in proxy_protocol.test.py and we noticed that the issue was due to the
handshake completing within a single call of sslStartHandshake. In those
cases, the ConnectingEntry handler wasn't called back and the connection
would hang without progressing with the rest of the request after the
handshake completed. This ensures that the ConnectingEntry handler is
called in these circumstances.
@bneradt bneradt force-pushed the fix_proxy_protocol_over_tls_hangs branch from b6905c9 to 780a42a Compare July 18, 2024 21:47
@bneradt bneradt changed the title Dispatch READ_COMPLETE when TLS handshake complete Dispatch WRITE_COMPLETE when TLS handshake completes Jul 18, 2024
@bneradt bneradt merged commit de2c354 into apache:master Jul 19, 2024
@bneradt bneradt deleted the fix_proxy_protocol_over_tls_hangs branch July 19, 2024 14:51
@cmcfarlen cmcfarlen modified the milestones: 10.1.0, 10.0.0 Jul 21, 2024
@cmcfarlen
Copy link
Copy Markdown
Contributor

Cherry-picked to v10.0.x

cmcfarlen pushed a commit that referenced this pull request Jul 21, 2024
The SSLNetVConnection.cc logic already does this, so this is a port over
of that event dispatch functionality when ntodo is 0 for
UnixNetVConnection.cc. @JosiahWI and I investigated a periodic failure
in proxy_protocol.test.py and we noticed that the issue was due to the
handshake completing within a single call of sslStartHandshake. In those
cases, the ConnectingEntry handler wasn't called back and the connection
would hang without progressing with the rest of the request after the
handshake completed. This ensures that the ConnectingEntry handler is
called in these circumstances.

(cherry picked from commit de2c354)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: picked-10.0.0

Development

Successfully merging this pull request may close these issues.

Client connection may time out in proxy_protocol AuTest

4 participants