[PATCH spice-server 2/2] RFC: Handle timeout for joining drawables

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

 



The previous patch join correctly the commands however if there
are no more commands the command joined is delayed till new
commands arrive. This patch introduce a timeout (currently 10 ms)
after the command is executed.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/red-worker.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/server/red-worker.c b/server/red-worker.c
index b841782..9feb130 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -85,6 +85,7 @@ struct RedWorker {
     RedRecord *record;
     GMainLoop *loop;
 
+    uint64_t joinable_timeout;
     RedDrawable *joinable_drawable;
 };
 
@@ -330,7 +331,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
                 continue;
             }
             worker->display_poll_tries++;
-            return n;
+            goto exit;
         }
 
         if (worker->record) {
@@ -368,6 +369,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
                     red_drawable_unref(worker->joinable_drawable);
                 }
                 // try to join with next one
+                worker->joinable_timeout = spice_get_monotonic_time_ns() + NSEC_PER_SEC / 100;
                 worker->joinable_drawable = red_drawable;
                 break;
             }
@@ -425,10 +427,23 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
         if (red_channel_all_blocked(RED_CHANNEL(worker->display_channel))
             || spice_get_monotonic_time_ns() - start > NSEC_PER_SEC / 100) {
             worker->event_timeout = 0;
-            return n;
+            goto exit;
         }
     }
     worker->was_blocked = TRUE;
+
+exit:
+    // check pending joinable
+    if (worker->joinable_drawable) {
+        if (spice_get_monotonic_time_ns() >= worker->joinable_timeout) {
+            display_channel_process_draw(worker->display_channel, worker->joinable_drawable,
+                                         worker->process_display_generation);
+            red_drawable_unref(worker->joinable_drawable);
+            worker->joinable_drawable = NULL;
+        } else {
+            worker->event_timeout = MIN(worker->event_timeout, 10);
+        }
+    }
     return n;
 }
 
-- 
2.9.3

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




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