[Spice-devel] [PATCH 6/7] red_worker: implements handle_dev_close

Frediano Ziglio fziglio at redhat.com
Wed Oct 14 08:37:35 PDT 2015


Cleanup properly the working thread.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red_worker.c | 34 ++++++++++++++++++++++++++++++++++
 server/reds.c       |  2 ++
 2 files changed, 36 insertions(+)

diff --git a/server/red_worker.c b/server/red_worker.c
index 7e11752..955ea8f 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -11846,6 +11846,40 @@ void handle_dev_driver_unload(void *opaque, void *payload)
 
 SPICE_GNUC_NORETURN static void handle_dev_close(void *opaque, void *payload)
 {
+    RedWorker *worker = opaque;
+    unsigned cnt;
+    _Drawable *dr;
+    _CursorItem *cursor;
+    Stream *stream;
+
+    monitors_config_decref(worker->monitors_config);
+    dev_destroy_surfaces(worker);
+    image_cache_reset(&worker->image_cache);
+    red_memslot_info_destroy(&worker->mem_slots);
+    jpeg_encoder_destroy(worker->jpeg);
+    lz_destroy(worker->lz);
+    zlib_encoder_destroy(worker->zlib);
+    quic_destroy(worker->quic);
+#ifdef USE_LZ4
+    lz4_encoder_destroy(worker->lz4);
+#endif
+
+    for (cnt = 0, dr = worker->free_drawables; dr; ++cnt, dr = dr->u.next)
+        continue;
+    spice_assert(cnt == NUM_DRAWABLES);
+
+    for (cnt = 0, cursor = worker->free_cursor_items; cursor; ++cnt, cursor = cursor->u.next)
+        continue;
+    spice_assert(cnt == NUM_CURSORS);
+
+    for (cnt = 0, stream = worker->free_streams; stream; ++cnt, stream = stream->next)
+        continue;
+    spice_assert(cnt == NUM_STREAMS);
+    spice_assert(ring_is_empty(&worker->streams));
+
+    for (cnt = 0; cnt < NUM_SURFACES; ++cnt)
+        spice_assert(worker->surfaces[cnt].context.canvas == NULL);
+    free(worker);
     pthread_exit(NULL);
 }
 
diff --git a/server/reds.c b/server/reds.c
index 5993863..ef8e676 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3242,6 +3242,8 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
         free(qxl->st);
         qxl->st = NULL;
     } else {
+        /* TODO SPICE_INTERFACE_KEYBOARD SPICE_INTERFACE_MOUSE
+         * SPICE_INTERFACE_MIGRATION */
         spice_warning("VD_INTERFACE_REMOVING unsupported");
         return -1;
     }
-- 
2.4.3



More information about the Spice-devel mailing list