[PATCH 4/9] worker: avoid server hanging when no client are connected.

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

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>

---
 server/red-worker.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/server/red-worker.c b/server/red-worker.c
index 9f2aba1..a57301c 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -227,7 +227,6 @@ static int red_process_display(RedWorker *worker, uint32_t max_pipe_size, int *r
 {
     QXLCommandExt ext_cmd;
     int n = 0;
-    uint64_t start = red_get_monotonic_time();
 
     if (!worker->running) {
         *ring_is_empty = TRUE;
@@ -236,8 +235,23 @@ static int red_process_display(RedWorker *worker, uint32_t max_pipe_size, int *r
 
     worker->process_display_generation++;
     *ring_is_empty = FALSE;
-    while (!display_is_connected(worker) ||
-           red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <= max_pipe_size) {
+    for (;;) {
+
+        if (display_is_connected(worker)) {
+
+            if (red_channel_all_blocked(RED_CHANNEL(worker->display_channel))) {
+                spice_info("all display clients are blocking");
+                return n;
+            }
+
+
+            // TODO: change to average pipe size?
+            if (red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) > max_pipe_size) {
+                spice_info("too many items in the display clients pipe already");
+                return n;
+            }
+        }
+
         if (!worker->qxl->st->qif->get_command(worker->qxl, &ext_cmd)) {
             *ring_is_empty = TRUE;;
             if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
@@ -327,13 +341,8 @@ static int red_process_display(RedWorker *worker, uint32_t max_pipe_size, int *r
             spice_error("bad command type");
         }
         n++;
-        if ((worker->display_channel &&
-             red_channel_all_blocked(&worker->display_channel->common.base))
-            || red_get_monotonic_time() - start > 10 * 1000 * 1000) {
-            worker->event_timeout = 0;
-            return n;
-        }
     }
+
     return n;
 }
 
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]