[gvfs/gnome-3-8] daemon: Emit signal before returning dbus value



commit ee2a74ce572209b746438b9faf558c009f037a78
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Sat Sep 21 22:22:27 2013 +0200

    daemon: Emit signal before returning dbus value
    
    In gvfsjobopenforread.c, the dbus method returns a value in create_reply
    which eventually results in a GVfsJobRead job to be sent to the backend.
    This could happen before the "new-source" signal is emitted.  If this
    happens, the job is not queued because the "new_job" signal would not
    have been connected to a job source yet.  The read then hangs because
    the GVfsJobRead is lost.
    
    This is hit often when performing large smb transfers (see
    https://bugzilla.gnome.org/show_bug.cgi?id=697782 and
    https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/1075923).
    It can be reproduced by putting a small sleep before the
    g_signal_emit_by_name call.
    
    Fix this by emitting the "new-source" signal *before* the dbus method
    value is returned.  This ensures that the "new_job" signal is set up
    before any further jobs are sent.
    
    Note that the same problem and solution applies for
    gvfsjobopenforwrite.c.

 daemon/gvfsjobopenforread.c  |   12 ++++++------
 daemon/gvfsjobopenforwrite.c |   12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/daemon/gvfsjobopenforread.c b/daemon/gvfsjobopenforread.c
index d978136..41b5f34 100644
--- a/daemon/gvfsjobopenforread.c
+++ b/daemon/gvfsjobopenforread.c
@@ -194,6 +194,12 @@ create_reply (GVfsJob *job,
       g_error_free (error);
     }
 
+  g_vfs_channel_set_backend_handle (G_VFS_CHANNEL (channel), open_job->backend_handle);
+  open_job->backend_handle = NULL;
+  open_job->read_channel = channel;
+
+  g_signal_emit_by_name (job, "new-source", channel);
+
   if (open_job->read_icon)
     gvfs_dbus_mount_complete_open_icon_for_read (object, invocation,
                                                  fd_list, g_variant_new_handle (fd_id),
@@ -206,12 +212,6 @@ create_reply (GVfsJob *job,
   /* FIXME: this could cause issues as long as fd_list closes all its fd's when it's finalized */
   close (remote_fd);
   g_object_unref (fd_list);
-  
-  g_vfs_channel_set_backend_handle (G_VFS_CHANNEL (channel), open_job->backend_handle);
-  open_job->backend_handle = NULL;
-  open_job->read_channel = channel;
-
-  g_signal_emit_by_name (job, "new-source", open_job->read_channel);
 }
 
 static void
diff --git a/daemon/gvfsjobopenforwrite.c b/daemon/gvfsjobopenforwrite.c
index a63e9cd..429e267 100644
--- a/daemon/gvfsjobopenforwrite.c
+++ b/daemon/gvfsjobopenforwrite.c
@@ -278,6 +278,12 @@ create_reply (GVfsJob *job,
       g_error_free (error);
     }
 
+  g_vfs_channel_set_backend_handle (G_VFS_CHANNEL (channel), open_job->backend_handle);
+  open_job->backend_handle = NULL;
+  open_job->write_channel = channel;
+
+  g_signal_emit_by_name (job, "new-source", open_job->write_channel);
+
   gvfs_dbus_mount_complete_open_for_write (object, invocation,
                                            fd_list, g_variant_new_handle (fd_id),
                                            open_job->can_seek,
@@ -285,12 +291,6 @@ create_reply (GVfsJob *job,
   
   close (remote_fd);
   g_object_unref (fd_list);
-
-  g_vfs_channel_set_backend_handle (G_VFS_CHANNEL (channel), open_job->backend_handle);
-  open_job->backend_handle = NULL;
-  open_job->write_channel = channel;
-
-  g_signal_emit_by_name (job, "new-source", open_job->write_channel);
 }
 
 static void


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