Skip to content

refactor(event): centralize NIO handshake dispatch - #889

Merged
ithewei merged 9 commits into
masterfrom
refactor/event-io-phase
Sep 25, 2026
Merged

ithewei merged 9 commits into
masterfrom
refactor/event-io-phase

Conversation

@ithewei

@ithewei ithewei commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add explicit NIO transport phases, including proxy and TLS established transitions
  • keep hio_handle_events as the single readiness dispatcher and move TLS handshake mechanics into internal event/tls.c
  • defer application writes until proxy/TLS handshakes finish
  • document callback, reentrancy, and buffer lifetime semantics
  • add regression coverage for phase transitions, pre-connect writes, and a real OpenSSL client/server TLS handshake

Architecture

  • event/proxy.c and event/tls.c manage their protocol stages and report completion through HIO_PHASE_PROXY_ESTABLISHED / HIO_PHASE_TLS_ESTABLISHED
  • event/nio.c owns cross-stage progression and invokes user accept_cb / connect_cb only after final HIO_PHASE_ESTABLISHED
  • no completion callback is injected back into proxy or TLS modules

Scope

This refactor applies to the non-IOCP NIO path. The existing IOCP implementation is unchanged.

Testing

  • clean default build: make clean && ./configure --without-openssl && make libhv unittest
  • DYLD_LIBRARY_PATH=lib bin/hio_phase_test
  • bash scripts/unittest.sh
  • CMake build of hio_phase_test
  • Homebrew OpenSSL CMake build and real client/server TLS handshake test
  • local tcp_echo_server + socks5_proxy_server + socks5_client_test end-to-end check

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI lite review requested due to automatic review settings September 25, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 08:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 09:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 11:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
Copilot AI review requested due to automatic review settings September 25, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ithewei
ithewei merged commit e8a3bf4 into master Sep 25, 2026
12 checks passed
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