Skip to contentSkip to conversation

ui/vnc: set TCP_NODELAY

PATCH Superseded Peter Lieven 2 participants 3 messages Sep 2, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/vnc: set TCP_NODELAY

we currently have the Nagle algorithm enabled for all outgoing VNC updates. This may delay sensitive updates as mouse movements or typing in the console. As we currently prepare all data in a buffer and then send as much as we can this should not cause big trouble. Well established VNC servers like TightVNC set TCP_NODELAY as well.
A regular framebuffer update request generates exactly one framebuffer update which should be pushed out as fast as possible.

---
 ui/vnc.c |    4 ++++
 1 file changed, 4 insertions(+)
ui/vnc.c +4 -0
index 1bc1ae0..b12d0ea 100644
@@ -2885,6 +2885,10 @@ static void vnc_listen_read(void *opaque, bool websocket)
     }
 
     if (csock != -1) {
+#ifdef TCP_NODELAY
+        int flag = 1;
+        setsockopt(csock, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+#endif
         vnc_connect(vs, csock, false, websocket);
     }
 }
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 18 lines · Peter Lieven

we currently have the Nagle algorithm enabled for all outgoing VNC updates. This may delay sensitive updates as mouse movements or typing in the console. As we currently prepare all data in a buffer and then send as much as we can this should not cause big trouble. Well established VNC servers like TightVNC set TCP_NODELAY as well.
A regular framebuffer update request generates exactly one framebuffer update which should be pushed out as fast as possible.

---
 ui/vnc.c |    4 ++++
 1 file changed, 4 insertions(+)
ui/vnc.c +0 -0
index 1bc1ae0..b12d0ea 100644

ui/vnc.c static void vnc_listen_read(void *opaque, bool websocket) · line 2892

Quoted 8 lines
ui/vnc.c +4 -0
@@ -2885,6 +2885,10 @@ static void vnc_listen_read(void *opaque, bool websocket)
     }
 
     if (csock != -1) {
+#ifdef TCP_NODELAY
+        int flag = 1;
+        setsockopt(csock, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+#endif
         vnc_connect(vs, csock, false, websocket);

Why not just call socket_set_nodelay() ?

thanks
-- PMM

#2 lore raw
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Peter Lieven

we currently have the Nagle algorithm enabled for all outgoing VNC updates. This may delay sensitive updates as mouse movements or typing in the console. As we currently prepare all data in a buffer and then send as much as we can this should not cause big trouble. Well established VNC servers like TightVNC set TCP_NODELAY as well.
A regular framebuffer update request generates exactly one framebuffer update which should be pushed out as fast as possible.

---
  ui/vnc.c |    4 ++++
  1 file changed, 4 insertions(+)
ui/vnc.c +0 -0
index 1bc1ae0..b12d0ea 100644
@@ -2885,6 +2885,10 @@ static void vnc_listen_read(void *opaque, bool websocket)
      }
 
Quoted 7 lines

ui/vnc.c static void vnc_listen_read(void *opaque, bool websocket) · line 2892

Quoted 6 lines
ui/vnc.c +4 -0
      if (csock != -1) {
+#ifdef TCP_NODELAY
+        int flag = 1;
+        setsockopt(csock, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+#endif
          vnc_connect(vs, csock, false, websocket);

Why not just call socket_set_nodelay() ?

I was not aware of that helper function. Thanks for the pointer.

Peter

Quoted 3 lines

thanks
-- PMM