[gvfs/nfs] nfs: Clear GSource after destroying it



commit a71201a48552b5adace694b95eb81912418c8c59
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Wed Jan 28 23:27:26 2015 +0000

    nfs: Clear GSource after destroying it
    
    Clear GSource after destroying to prevent an extra unref when
    finalizing.

 daemon/gvfsbackendnfs.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/daemon/gvfsbackendnfs.c b/daemon/gvfsbackendnfs.c
index 66d6a24..845576f 100644
--- a/daemon/gvfsbackendnfs.c
+++ b/daemon/gvfsbackendnfs.c
@@ -117,11 +117,14 @@ nfs_source_prepare (GSource *source, gint *timeout)
 
   if (fd < 0)
     {
-      g_vfs_backend_force_unmount (G_VFS_BACKEND (nfs_source->backend));
+      GVfsBackendNfs *backend = nfs_source->backend;
+
+      g_vfs_backend_force_unmount (G_VFS_BACKEND (backend));
       nfs_destroy_context (nfs_source->ctx);
-      nfs_source->backend->ctx = NULL;
+      backend->ctx = NULL;
       g_source_destroy (source);
       g_source_unref (source);
+      backend->source = NULL;
     }
   else if (fd != nfs_source->fd)
     {
@@ -149,13 +152,16 @@ nfs_source_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
                      g_source_query_unix_fd (source, nfs_source->tag));
   if (err)
     {
+      GVfsBackendNfs *backend = nfs_source->backend;
+
       g_warning ("nfs_service error: %d, %s\n",
                  err, nfs_get_error (nfs_source->ctx));
-      g_vfs_backend_force_unmount (G_VFS_BACKEND (nfs_source->backend));
+      g_vfs_backend_force_unmount (G_VFS_BACKEND (backend));
       nfs_destroy_context (nfs_source->ctx);
-      nfs_source->backend->ctx = NULL;
+      backend->ctx = NULL;
       g_source_destroy (source);
       g_source_unref (source);
+      backend->source = NULL;
     }
 
   return G_SOURCE_CONTINUE;


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