Files
cc-connect/platform/weibo
Shawn 9cfe29b8b0 fix(weibo): serialize writeWS with wsMu to honor gorilla/websocket single-writer contract (#940)
writeWS held wsMu only to read p.ws, then released the mutex before
calling ws.WriteJSON. Concurrent senders (sendMessage / SendImage /
SendFile from the engine, plus the pingLoop heartbeat which DID hold
the mutex through its own WriteJSON) could therefore enter WriteJSON
in parallel. gorilla/websocket explicitly requires that no more than
one goroutine call the write methods at a time and panics on detection:
"panic: concurrent write to websocket connection".

Hold wsMu through the entire WriteJSON, matching the pattern pingLoop
already uses. Adds a regression test that fires 50 concurrent sends
against an httptest websocket server; under -race the buggy version
reliably panics in gorilla's beginMessage, while the fixed version
serializes cleanly and the server receives all 50 frames as valid JSON.
2026-05-18 10:24:07 +08:00
..