[Spice-devel] [PATCH spice-gtk 4/4] qmp: clear all pending tasks on close event
marcandre.lureau at redhat.com
marcandre.lureau at redhat.com
Wed Sep 26 14:56:24 UTC 2018
From: Marc-André Lureau <marcandre.lureau at redhat.com>
g_hash_table_remove() will call the free handler and dispose the
pending tasks.
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
src/qmp-port.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/qmp-port.c b/src/qmp-port.c
index 89b27aa..c91f967 100644
--- a/src/qmp-port.c
+++ b/src/qmp-port.c
@@ -209,6 +209,15 @@ static void spice_qmp_port_dispose(GObject *gobject)
G_OBJECT_CLASS(spice_qmp_port_parent_class)->dispose(gobject);
}
+static void spice_qmp_handle_port_event(SpiceQmpPort *self, gint event)
+{
+ SPICE_DEBUG("QMP port event:%d", event);
+
+ if (event == SPICE_PORT_EVENT_CLOSED) {
+ g_hash_table_remove_all(self->priv->qmp_tasks);
+ }
+}
+
static void spice_qmp_port_constructed(GObject *gobject)
{
SpiceQmpPort *self = SPICE_QMP_PORT(gobject);
@@ -220,6 +229,10 @@ static void spice_qmp_port_constructed(GObject *gobject)
"port-data", G_CALLBACK(spice_qmp_handle_port_data),
self, G_CONNECT_SWAPPED);
+ spice_g_signal_connect_object(self->priv->channel,
+ "port-event", G_CALLBACK(spice_qmp_handle_port_event),
+ self, G_CONNECT_SWAPPED);
+
if (G_OBJECT_CLASS(spice_qmp_port_parent_class)->constructed)
G_OBJECT_CLASS(spice_qmp_port_parent_class)->constructed(gobject);
}
--
2.19.0.271.gfe8321ec05
More information about the Spice-devel
mailing list