End a read() assembling fragments once close() is called (#2683)

A read() assembling a fragmented message looped over continuation
frames without looking at closed_, which the loop over frames checks.
A peer that kept sending fragments, empty ones included, never let the
read reach a wait, so a close() from another thread could not end it.
The read now ends with Fail once the connection is closed.
This commit is contained in:
Pascal authored and GitHub committed 2026-11-18 12:13:13 -05:00
1 parent 92435b31b3
commit baba35b8d3
2 files changed
+57

No files matched your search

+4
View File
@@ -23884,6 +23884,10 @@ inline ReadResult WebSocket::read(std::string &msg) {
// Handle fragmentation
if (!fin) {
while (true) {
// A close() from another thread ends the message being assembled,
// as it ends the loop over frames above: a peer that keeps sending
// fragments never lets a read reach a wait
if (closed_) { return Fail; }
Opcode cont_opcode;
std::string cont_payload;
bool cont_fin;