ws: fix write callback error handling

When websocket writes out data thought the registered write callback and
that returns an error, clear the write buffers, so a sub-sequent flush
will not attempt another write. The transfer is failed at that point and
should no longer invoke the callback.

Fixes #22627
Reported-by: Scott Talbert
Closes #22634
This commit is contained in:
Stefan Eissing 2026-08-21 11:50:33 +02:00 committed by Daniel Stenberg
parent 5d6dc81678
commit 7e7ee16dd3
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 155 additions and 3 deletions

View file

@ -754,7 +754,8 @@ static CURLcode ws_cw_write(struct Curl_easy *data,
}
else if(result) {
failf(data, "[WS] decode payload error %d", (int)result);
return result;
Curl_bufq_reset(&ctx->buf);
goto out;
}
}
@ -812,7 +813,8 @@ static CURLcode ws_cw_flush(struct Curl_easy *data,
}
else if(result) {
failf(data, "[WS] decode payload error %d", (int)result);
return result;
Curl_bufq_reset(&ctx->buf);
goto out;
}
}
}