Re: [PATCH virt-viewer 2/9] spice: calling VirtViewerSession:close() can destroy self

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

 





On Thu, Nov 13, 2014 at 6:20 PM, Marc-André Lureau <marcandre.lureau@xxxxxxxxx> wrote:
SpiceSession in spice-gtk v0.27 removes channels from session during
disconnect (and not when they are actually disposed). When no channels
are left, session-disconnected is emitted, and the VirtViewerSession
will be unref from the application. Use a weak reference to self to
avoid crashing after calling spice_session_disconnect()

As a workaround for existing clients, spice-gtk v0.27 will defer the
disconnection to idle time.  But the fix still makes sense and would
prevent potentially future issues if spice-gtk changes back to sync
disconnection.

(the alternative of calling ref/unref would keep recreating session,
 which is something it can avoid when leaving the application)
---
 src/virt-viewer-session-spice.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 2eb2224..afeeadd 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -292,10 +292,15 @@ virt_viewer_session_spice_close(VirtViewerSession *session)

     g_return_if_fail(self != NULL);

+    g_object_add_weak_pointer(G_OBJECT(self), (gpointer*)&self);
+
     virt_viewer_session_clear_displays(session);

     if (self->priv->session) {
         spice_session_disconnect(self->priv->session);
+        if (!self)
+            return;
         g_object_unref(self->priv->session);
         self->priv->session = NULL;
         self->priv->gtk_session = NULL;

It's missing g_object_remove_weak_pointer() which I just added.
 
--
1.9.3




--
Marc-André Lureau
_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux