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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]