[Spice-devel] [PATCH spice-server 13/23] websocket: Fix updating remaining bytes to write in websocket_write

Frediano Ziglio fziglio at redhat.com
Tue Jun 25 16:11:37 UTC 2019


"len" is not always the full remainder (consider the case when
we are writing a partial frame).

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/websocket.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/server/websocket.c b/server/websocket.c
index afb7502a1..dda71f768 100644
--- a/server/websocket.c
+++ b/server/websocket.c
@@ -478,10 +478,8 @@ int websocket_write(RedsWebSocket *ws, const void *buf, size_t len)
     }
 
     rc = ws->raw_write(ws->raw_stream, buf, len);
-    if (rc <= 0) {
-        ws->write_remainder = len;
-    } else {
-        ws->write_remainder = len - rc;
+    if (rc > 0) {
+        ws->write_remainder -= rc;
     }
     return rc;
 }
-- 
2.20.1



More information about the Spice-devel mailing list