Skip to content

Fix graceful shutdown support#87

Merged
aryan-25 merged 1 commit into
swift-server:mainfrom
aryan-25:graceful-shutdown-on-all-bound-channels
Jun 3, 2026
Merged

Fix graceful shutdown support#87
aryan-25 merged 1 commit into
swift-server:mainfrom
aryan-25:graceful-shutdown-on-all-bound-channels

Conversation

@aryan-25

@aryan-25 aryan-25 commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Motivation:

In #79, we introduced support for binding to multiple addresses. However, since all bound channels share a single ServerQuiescingHelper, this means only the first bound server channel supports graceful shutdown. In addition to this, due to the way #79 handles the cleanup of server channels, as soon as one channel finishes, all other channels are immediately shut down. This means that in-flight requests on every other listener are dropped immediately when _serve returns after the first listener finished. Since different channels may complete draining at different times, we should also fix this.

Modifications:

  • Modified the HTTP/1.1 and secure upgrade channel setup methods to set up a ServerQuiescingHelper for each bound channel.
  • Modified the cases of the ServerChannel enum to store the associated ServerQuiescingHelper.
  • Modified the beginGracefulShutdown method to now iterate every listener and initiate shutdown on each.
  • Refactored the _serve task-group to wait for all listeners to finish, and only tear the whole server down on an error.
  • Added associated tests.

Result:

Graceful shutdown is now supported on every bound channel.

@aryan-25 aryan-25 added the 🔨 semver/patch No public API change. label Jun 2, 2026
@aryan-25 aryan-25 requested a review from gjcairo June 3, 2026 13:03
@aryan-25 aryan-25 merged commit b1c4f77 into swift-server:main Jun 3, 2026
19 of 21 checks passed
@aryan-25 aryan-25 deleted the graceful-shutdown-on-all-bound-channels branch June 3, 2026 17:07
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.

2 participants