Skip to content

Fix infinite loop when ErrStreamAlreadyExist occurs for in-band data channels#2

Open
timwu20 wants to merge 1 commit into0.13from
tim/0.13
Open

Fix infinite loop when ErrStreamAlreadyExist occurs for in-band data channels#2
timwu20 wants to merge 1 commit into0.13from
tim/0.13

Conversation

@timwu20
Copy link
Collaborator

@timwu20 timwu20 commented Feb 10, 2026

Summary

  • Fix three error paths in RtcSctp::do_poll() where continue skips close handling, causing entries to stay in AwaitOpen state indefinitely
  • Affected entries are now immediately transitioned to Closed and emit SctpEvent::Close

Problem

When an in-band (DCEP) data channel fails to open with ErrStreamAlreadyExist, the stream entry has do_close = true set but the continue statement skips the close handling at the bottom of the loop. Since state remains AwaitOpen, subsequent polls retry the open — creating an infinite loop of warnings and eventually causing a panic (writing dcep open: ErrPayloadDataStateNotExist).

This is triggered when both peers try to open data channels simultaneously and the automatic stream ID allocation conflicts with a stream already opened by the remote peer.

Fix

In do_poll(), three error paths inside the if want_open block used continue after setting do_close = true, which skipped the close-handling code further down the loop body:

  1. configure_reliability failure
  2. ErrStreamAlreadyExist for in-band channels
  3. Generic open_stream errors

All three now transition the entry to Closed and return SctpEvent::Close directly instead of continue-ing.

Test plan

  • Existing test suite passes (cargo test — 0 failures)
  • Manual verification with simultaneous data channel opens from both peers

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

Comments