[PATCH spice-gtk 4/4] qmp: clear all pending tasks on close event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

g_hash_table_remove() will call the free handler and dispose the
pending tasks.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]