diff --git a/src/guacd/daemon.c b/src/guacd/daemon.c index 1701a366..dab531cf 100644 --- a/src/guacd/daemon.c +++ b/src/guacd/daemon.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -546,6 +547,12 @@ int main(int argc, char* argv[]) { continue; } + /* Set TCP_NODELAY to avoid any latency that would otherwise be added by the OS' + * networking stack and Nagle's algorithm */ + const int SO_TRUE = 1; + setsockopt(connected_socket_fd, IPPROTO_TCP, TCP_NODELAY, + (const void*) &SO_TRUE, sizeof(SO_TRUE)); + /* Create parameters for connection thread */ guacd_connection_thread_params* params = guac_mem_alloc(sizeof(guacd_connection_thread_params)); if (params == NULL) { diff --git a/src/libguac/display-flush.c b/src/libguac/display-flush.c index 44436168..10f9667c 100644 --- a/src/libguac/display-flush.c +++ b/src/libguac/display-flush.c @@ -176,6 +176,12 @@ static int PFW_LFW_guac_display_frame_complete(guac_display* display) { } + /* Even if nothing has changed in the pending frame, we have to at + * least flush that fact to the last frame (otherwise, the last frame + * may contain stale dirty rects) */ + else + current->last_frame.dirty = (guac_rect) { 0 }; + /* Commit any change in layer size */ if (current->pending_frame.width != current->last_frame.width || current->pending_frame.height != current->last_frame.height) { @@ -272,7 +278,9 @@ static int PFW_LFW_guac_display_frame_complete(guac_display* display) { display->last_frame.cursor_mask = display->pending_frame.cursor_mask; guac_client_foreach_user(client, LFR_guac_display_broadcast_cursor_state, display); - retval = 1; + /* NOTE: We DO NOT set retval here, as flushing a frame due purely to + * mouse position changes can cause slowdowns apparently from the sheer + * quantity of frames */ } diff --git a/src/libguac/display-worker.c b/src/libguac/display-worker.c index 39649f3f..a9bfb3be 100644 --- a/src/libguac/display-worker.c +++ b/src/libguac/display-worker.c @@ -454,10 +454,6 @@ void* guac_display_worker_thread(void* data) { } - /* Include an additional frame boundary to allow the client to also move forward with committing - * changes to the backing buffer while the server is receiving and preparing the next frame */ - guac_client_end_multiple_frames(client, 0); - /* This is now absolutely everything for the current frame, * and it's safe to flush any outstanding data */ guac_socket_flush(client->socket);