Skip to content

fix: add recurrent graceful close for raw TCP - #13

Merged
kentbull merged 1 commit into
release/v0.6.20from
p0/recurrent-tcp-close-v0.6.20
Aug 27, 2026
Merged

kentbull merged 1 commit into
release/v0.6.20from
p0/recurrent-tcp-close-v0.6.20

Conversation

@kentbull

@kentbull kentbull commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Add recurrent graceful close for raw Client and Remoter.
  • Drain queued output before issuing local SHUT_WR.
  • Wait until local receive observes peer write EOF before final disposal.
  • Retain write-shutdown failures and keep TLS on its separate force-close path.

Why

Immediate close can discard accepted output. Raw TCP shutdown is directional: graceful close must settle egress before local write shutdown and keep local receive available for final peer input.

Background

This is a recurrent transport primitive, not an owner state machine. Higher-level owners remain responsible for protocol completion, continued service, deadlines, and choosing force-close when settlement cannot finish.

Boundary

This PR does not define HTTP framing policy, owner deadlines, or TLS close_notify shutdown.

Add a small Client and Remoter close primitive that waits for queued output, shuts down writes once, waits for peer EOF, and then closes. Shutdown failures remain visible through the endpoint error and direction state.

Client now records successful local half-closes. TLS force-close overrides bypass raw socket shutdown so this raw bookkeeping does not change TLS semantics before recurrent close_notify support lands.
@kentbull
kentbull merged commit 743f31b into release/v0.6.20 Aug 27, 2026
6 checks passed
@kentbull
kentbull deleted the p0/recurrent-tcp-close-v0.6.20 branch August 27, 2026 10:50
@kentbull

kentbull commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Upstream prerequisite: an accepted directional-state and terminal-cause contract for Client and Remoter, equivalent to #9/#10 and the Remoter behavior proposed by ioflo#163.

This raw TCP behavior does not depend on #11/#12's TLS classifications. It can be adapted once queued output drains independently of local receive EOF and local write shutdown can be represented without conflating both directions.

@kentbull kentbull changed the title fix: drain raw TCP output before recurrent close fix: delay raw TCP half-close until output drains Aug 28, 2026
@kentbull

kentbull commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Implements downstream behavior for ioflo#175 by adding recurrent graceful close for raw Client and Remoter: drain accepted output, issue local SHUT_WR, wait until local receive observes peer write EOF, then dispose of the socket. #16 adds real-socket coverage.

@kentbull kentbull changed the title fix: delay raw TCP half-close until output drains fix: add recurrent graceful close for raw TCP Aug 29, 2026
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.

1 participant