Skip to content

websocket: prevent HTTP disconnect deadlock by deferring writable callbacks (#2197) - #2206

Open
darwvin-dev wants to merge 7 commits into
sipwise:masterfrom
darwvin-dev:fix/websocket-disconnect-deadlock-2197
Open

darwvin-dev wants to merge 7 commits into
sipwise:masterfrom
darwvin-dev:fix/websocket-disconnect-deadlock-2197

Conversation

@darwvin-dev

Copy link
Copy Markdown
Contributor

Fork-local draft for upstream #2197.

Changes

  • Replace spinning for websocket_service_lock with a short mutex-protected writable queue.
  • Ensure all lws_callback_on_writable() calls occur on the LWS service thread after lws_service() exits.
  • Release callback queue mutex before calling libwebsockets, and bound the amount of queued work consumed per service cycle to avoid starvation.
  • Drop pending callbacks on connection teardown before freeing LWS session storage.
  • Integrate HTTP disconnect stress into t/auto-daemon-tests-websocket.py using two HTTP workers and add a standalone stress script.

Validation / upstream readiness

  • Commit source changes and stress tests to a dedicated fork branch.
  • Run make asan-check, make -C t daemon-tests-websocket, full HTTP/WS suite.
  • Execute repeated close/reset storms with ASAN / TSAN where supported.
  • Verify compatibility with supported libwebsockets 2.x/3.x/4.x combinations.

No build or runtime test has yet been executed here. Draft only.


Upstream submission notes

This is a draft, carried from contributor fork PR darwvin-dev/rtpengine#5.
Unfinished validation: Please refer to the outstanding build, runtime, regression and/or integration tests above. No claim is made that these checks passed. Review for compatibility and completeness before marking ready.
The source branch is behind current upstream master and may require reconciliation before merging.

@darwvin-dev
darwvin-dev marked this pull request as ready for review October 17, 2026 12:59
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