[Spice-devel] [spice-server v2 7/9] qxl: Release QXL resource in red_put_message
Christophe Fergeau
cfergeau at redhat.com
Tue Apr 17 16:19:22 UTC 2018
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
server/red-parse-qxl.c | 6 ++++--
server/red-parse-qxl.h | 3 ++-
server/red-worker.c | 3 +--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index b0c47cfeb..a5e363579 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1266,7 +1266,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;
@@ -1285,6 +1285,7 @@ bool red_get_message(RedMemSlotInfo *slots, int group_id,
if (error) {
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;
@@ -1301,7 +1302,8 @@ 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 231844e96..c73462e0e 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -75,6 +75,7 @@ typedef struct RedUpdateCmd {
} RedUpdateCmd;
typedef struct RedMessage {
+ QXLInstance *qxl;
QXLReleaseInfoExt release_info_ext;
int len;
uint8_t *data;
@@ -127,7 +128,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 2dcf2b0ef..762443f7c 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -238,14 +238,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.14.3
More information about the Spice-devel
mailing list