Skip to content

Remove sleep from listeners, add Async task scoping to Server#run#7

Merged
henrikbjorn merged 1 commit intomasterfrom
remove-sleep-from-listeners
Mar 16, 2026
Merged

Remove sleep from listeners, add Async task scoping to Server#run#7
henrikbjorn merged 1 commit intomasterfrom
remove-sleep-from-listeners

Conversation

@henrikbjorn
Copy link
Copy Markdown
Member

Summary

  • Remove sleep from Inbound#run_session and Outbound#run_session — the read_loop in Client/Server keeps the connection alive, events are dispatched from the read_loop fiber not the session task
  • Wrap Server#run in Async do |task| with task.children.each(&:wait) to drain in-flight connections on shutdown, matching the async-http pattern

The sleep was added in 81014f3 to "keep session task alive for event hooks and child tasks" but event hooks are dispatched by handle_response which runs in the read_loop fiber, not the session task. The session task completing has no effect on event delivery.

The sleep in run_session was unnecessary — the read_loop in
Client/Server keeps the connection alive until FreeSWITCH closes it.
Server#run now wraps in Async do |task| with task.children.each(&:wait)
to properly drain in-flight connections on shutdown, matching the
async-http pattern.
@henrikbjorn henrikbjorn requested review from c960657 and mkyed March 16, 2026 08:51
@henrikbjorn henrikbjorn self-assigned this Mar 16, 2026
Copy link
Copy Markdown
Member

@mkyed mkyed left a comment

Choose a reason for hiding this comment

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

@henrikbjorn henrikbjorn merged commit ab88b50 into master Mar 16, 2026
3 checks passed
@henrikbjorn henrikbjorn deleted the remove-sleep-from-listeners branch March 16, 2026 12:46
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.

3 participants