mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
io: simplify websocket ping reply handling
We must ensure we don't get flooded with ping replies if the outbound channel is slow. Currently we do this by keeping the ping reply in a separate temporary buffer and only writing it if the encoutput buffer is completely empty. This is overly pessimistic, as it is reasonable to add a ping reply to the encoutput buffer even if it has previous data in it, as long as that previous data doesn't include a ping reply. To track this better, put the ping reply directly into the encoutput buffer, and then record the size of encoutput at this time in pong_remain. As we write encoutput to the underlying channel, we can decrement the pong_remain counter. Once it hits zero, we can accept further ping replies for transmission. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
a7b20a8efa
commit
57b0cdf152
2 changed files with 16 additions and 14 deletions
|
@ -60,8 +60,8 @@ struct QIOChannelWebsock {
|
|||
Buffer encoutput;
|
||||
Buffer rawinput;
|
||||
Buffer rawoutput;
|
||||
Buffer ping_reply;
|
||||
size_t payload_remain;
|
||||
size_t pong_remain;
|
||||
QIOChannelWebsockMask mask;
|
||||
guint io_tag;
|
||||
Error *io_err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue