[Spice-devel] [spice-server v4 05/11] qxl: Release QXL resource in red_put_message
Christophe Fergeau
cfergeau at redhat.com
Thu Nov 29 12:50:07 UTC 2018
---
server/red-parse-qxl.c | 7 +++++--
server/red-parse-qxl.h | 3 ++-
server/red-worker.c | 3 +--
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 7e6f5ce9d..4be53d3e5 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1261,7 +1261,7 @@ void red_put_update_cmd(RedUpdateCmd *red)
/* nothing yet */
}
-bool red_get_message(RedMemSlotInfo *slots, int group_id,
+bool red_get_message(QXLInstance *qxl_instance, RedMemSlotInfo *slots, int group_id,
RedMessage *red, QXLPHYSICAL addr)
{
QXLMessage *qxl;
@@ -1279,6 +1279,7 @@ bool red_get_message(RedMemSlotInfo *slots, int group_id,
if (qxl == NULL) {
return false;
}
+ red->qxl = qxl_instance;
red->release_info_ext.info = &qxl->release_info;
red->release_info_ext.group_id = group_id;
red->data = qxl->data;
@@ -1295,7 +1296,9 @@ bool red_get_message(RedMemSlotInfo *slots, int group_id,
void red_put_message(RedMessage *red)
{
- /* nothing yet */
+ if (red->qxl != NULL) {
+ red_qxl_release_resource(red->qxl, red->release_info_ext);
+ }
}
static unsigned int surface_format_to_bpp(uint32_t format)
diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h
index cb1c1b9fa..ecf7b1577 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -67,6 +67,7 @@ typedef struct RedUpdateCmd {
} RedUpdateCmd;
typedef struct RedMessage {
+ QXLInstance *qxl;
QXLReleaseInfoExt release_info_ext;
int len;
uint8_t *data;
@@ -121,7 +122,7 @@ bool red_get_update_cmd(RedMemSlotInfo *slots, int group_id,
RedUpdateCmd *red, QXLPHYSICAL addr);
void red_put_update_cmd(RedUpdateCmd *red);
-bool red_get_message(RedMemSlotInfo *slots, int group_id,
+bool red_get_message(QXLInstance *qxl, RedMemSlotInfo *slots, int group_id,
RedMessage *red, QXLPHYSICAL addr);
void red_put_message(RedMessage *red);
diff --git a/server/red-worker.c b/server/red-worker.c
index 58fe32d32..aa54dcd85 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -232,14 +232,13 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
case QXL_CMD_MESSAGE: {
RedMessage message;
- if (!red_get_message(&worker->mem_slots, ext_cmd.group_id,
+ if (!red_get_message(worker->qxl, &worker->mem_slots, ext_cmd.group_id,
&message, ext_cmd.cmd.data)) {
break;
}
#ifdef DEBUG
spice_warning("MESSAGE: %.*s", message.len, message.data);
#endif
- red_qxl_release_resource(worker->qxl, message.release_info_ext);
red_put_message(&message);
break;
}
--
2.19.1
More information about the Spice-devel
mailing list