Skip to content

Unconditionally insert TLSEventsHandler #349

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

Merged
merged 1 commit into from
Mar 18, 2021

Conversation

Lukasa
Copy link
Collaborator

@Lukasa Lukasa commented Mar 18, 2021

Motivation:

AsyncHTTPClient attempts to avoid the problem of Happy Eyeballs making
it hard to know which Channel will be returned by only inserting the
TLSEventsHandler upon completion of the connect promise. Unfortunately,
as this may involve event loop hops, there are some awkward timing
windows in play where the connect may complete before this handler gets
added.

We should remove that timing window by ensuring that all channels always
have this handler in place, and instead of trying to wait until we know
which Channel will win, we can find the TLSEventsHandler that belongs to
the winning channel after the fact.

Modifications:

  • TLSEventsHandler no longer removes itself from the pipeline or throws
    away its promise.
  • makeHTTP1Channel now searches for the TLSEventsHandler from the
    pipeline that was created and is also responsible for removing it.
  • Better sanity checking that the proxy TLS case does not overlap with
    the connection-level TLS case.

Results:

Further shrinking windows for pipeline management issues.

@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Mar 18, 2021
@Lukasa Lukasa requested review from artemredkin and weissi March 18, 2021 09:57
Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!

Copy link
Collaborator

@artemredkin artemredkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Motivation:

AsyncHTTPClient attempts to avoid the problem of Happy Eyeballs making
it hard to know which Channel will be returned by only inserting the
TLSEventsHandler upon completion of the connect promise. Unfortunately,
as this may involve event loop hops, there are some awkward timing
windows in play where the connect may complete before this handler gets
added.

We should remove that timing window by ensuring that all channels always
have this handler in place, and instead of trying to wait until we know
which Channel will win, we can find the TLSEventsHandler that belongs to
the winning channel after the fact.

Modifications:

- TLSEventsHandler no longer removes itself from the pipeline or throws
  away its promise.
- makeHTTP1Channel now searches for the TLSEventsHandler from the
  pipeline that was created and is also responsible for removing it.
- Better sanity checking that the proxy TLS case does not overlap with
  the connection-level TLS case.

Results:

Further shrinking windows for pipeline management issues.
@Lukasa Lukasa force-pushed the cb-handshake-result-handler branch from db8296a to 810f450 Compare March 18, 2021 11:34
@Lukasa Lukasa merged commit b075d19 into swift-server:main Mar 18, 2021
@Lukasa Lukasa deleted the cb-handshake-result-handler branch March 18, 2021 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants