Repository navigation
Fix one stalled client blocking WebSocket writes to all windows - #725
Merged
Merged
Conversation
`_webui_send_client_ws()` held the process-wide `mutex_send` around `mg_websocket_write()`. CivetWeb already locks the connection for the whole frame, so the global lock only made a client that stops reading block every other window and client for up to `request_timeout_ms` (30 s) per frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thank you for the PR, I think we still need to add |
AlbertShown
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #723
_webui_send_client_ws()no longer holds the process-wide_webui.mutex_sendaroundmg_websocket_write(). CivetWeb'smg_websocket_write_exec()already locks the connection for the whole frame, andclose_connection()takes the same lock. Frames to one connection therefore stay whole and ordered, and a client that stops reading blocks only its own writes. The unusedmutex_sendfield, init and destroy are removed. Nothing changes insrc/civetweb/orinclude/webui.h.Verified on Linux x64 with the reproducer from the issue: a stalled client on window A, and
webui_script()round trips to window B in headless Chromium for 65 s.Stress test: one multi-client window, 8 threads calling
webui_run()with frames of 0 to 128 KiB, back-to-backwebui.call()s from the page, and about 330 extra clients connecting and dropping (some with RST).🤖 Generated with Claude Code