[Spice-devel] [spice-server 10/10] qxl: Release QXL resources in red_put_update_cmd

Christophe Fergeau cfergeau at redhat.com
Mon Apr 16 10:13:59 UTC 2018


---
 server/red-parse-qxl.c | 10 +++++++---
 server/red-parse-qxl.h |  3 ++-
 server/red-worker.c    |  3 +--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index d4a7decd3..313cd1bfb 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1255,8 +1255,9 @@ static void red_put_drawable(RedDrawable *red)
     }
 }
 
-bool red_get_update_cmd(RedMemSlotInfo *slots, int group_id,
-                        RedUpdateCmd *red, QXLPHYSICAL addr)
+bool red_get_update_cmd(QXLInstance *qxl, RedMemSlotInfo *slots,
+                        int group_id, RedUpdateCmd *red,
+                        QXLPHYSICAL addr)
 {
     QXLUpdateCmd *qxl_cmd;
     int error;
@@ -1268,6 +1269,7 @@ bool red_get_update_cmd(RedMemSlotInfo *slots, int group_id,
     red->release_info_ext.info     = &qxl_cmd->release_info;
     red->release_info_ext.group_id = group_id;
 
+    red->qxl = qxl;
     red_get_rect_ptr(&red->area, &qxl_cmd->area);
     red->update_id  = qxl_cmd->update_id;
     red->surface_id = qxl_cmd->surface_id;
@@ -1276,7 +1278,9 @@ bool red_get_update_cmd(RedMemSlotInfo *slots, int group_id,
 
 void red_put_update_cmd(RedUpdateCmd *red)
 {
-    /* nothing yet */
+    if (red->qxl != NULL) {
+        red_qxl_release_resource(red->qxl, red->release_info_ext);
+    }
 }
 
 bool red_get_message(QXLInstance *qxl, RedMemSlotInfo *slots, int group_id,
diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h
index c73462e0e..c3ad39ea7 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -68,6 +68,7 @@ static inline RedDrawable *red_drawable_ref(RedDrawable *drawable)
 void red_drawable_unref(RedDrawable *red_drawable);
 
 typedef struct RedUpdateCmd {
+    QXLInstance *qxl;
     QXLReleaseInfoExt release_info_ext;
     SpiceRect area;
     uint32_t update_id;
@@ -124,7 +125,7 @@ RedDrawable *red_drawable_new(QXLInstance *qxl, RedMemSlotInfo *slots,
                               uint32_t flags);
 void red_drawable_unref(RedDrawable *red_drawable);
 
-bool red_get_update_cmd(RedMemSlotInfo *slots, int group_id,
+bool red_get_update_cmd(QXLInstance *qxl, RedMemSlotInfo *slots, int group_id,
                         RedUpdateCmd *red, QXLPHYSICAL addr);
 void red_put_update_cmd(RedUpdateCmd *red);
 
diff --git a/server/red-worker.c b/server/red-worker.c
index 762443f7c..62ee357ab 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -221,7 +221,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
         case QXL_CMD_UPDATE: {
             RedUpdateCmd update;
 
-            if (!red_get_update_cmd(&worker->mem_slots, ext_cmd.group_id,
+            if (!red_get_update_cmd(worker->qxl, &worker->mem_slots, ext_cmd.group_id,
                                     &update, ext_cmd.cmd.data)) {
                 break;
             }
@@ -231,7 +231,6 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
                 display_channel_draw(worker->display_channel, &update.area, update.surface_id);
                 red_qxl_notify_update(worker->qxl, update.update_id);
             }
-            red_qxl_release_resource(worker->qxl, update.release_info_ext);
             red_put_update_cmd(&update);
             break;
         }
-- 
2.14.3



More information about the Spice-devel mailing list