[gvfs] client: Use the correct serial with file transfer cancellation



commit a336ef412ace2f9fc169185c48bca657e28c646e
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Sun Dec 8 12:28:55 2013 +0200

    client: Use the correct serial with file transfer cancellation
    
    When using Copy, Move, Push and Pull with progress callbacks, the
    progress callbacks increment the connection serial, so retrieve the
    serial immediately after the dbus method call so that the correct serial
    is used for cancellation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720058

 client/gdaemonfile.c    |   14 ++++++++++++--
 client/gvfsdaemondbus.c |   13 +++++++++----
 client/gvfsdaemondbus.h |    2 ++
 3 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index cff031b..e97c9a4 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -2803,6 +2803,7 @@ file_transfer (GFile                  *source,
   GVfsDBusProgress *progress_skeleton;
   GFile *file1, *file2;
   GError *my_error;
+  guint32 serial;
 
   res = FALSE;
   progress_skeleton = NULL;
@@ -2810,6 +2811,7 @@ file_transfer (GFile                  *source,
   source_is_daemon = G_IS_DAEMON_FILE (source);
   dest_is_daemon   = G_IS_DAEMON_FILE (destination);
   send_progress    = progress_callback != NULL;
+  serial           = 0;
 
   if (source_is_daemon && dest_is_daemon)
     native_transfer = TRUE;
@@ -2911,6 +2913,7 @@ retry:
                                      cancellable,
                                      copy_cb,
                                      &data);
+          serial = g_dbus_connection_get_last_serial (connection);
           g_main_loop_run (data.loop);
           res = gvfs_dbus_mount_call_copy_finish (proxy, data.res, &my_error);
         }
@@ -2923,6 +2926,7 @@ retry:
                                      cancellable,
                                      copy_cb,
                                      &data);
+          serial = g_dbus_connection_get_last_serial (connection);
           g_main_loop_run (data.loop);
           res = gvfs_dbus_mount_call_move_finish (proxy, data.res, &my_error);
         }
@@ -2939,6 +2943,7 @@ retry:
                                  cancellable,
                                  copy_cb,
                                  &data);
+      serial = g_dbus_connection_get_last_serial (connection);
       g_main_loop_run (data.loop);
       res = gvfs_dbus_mount_call_push_finish (proxy, data.res, &my_error);
     }
@@ -2954,6 +2959,7 @@ retry:
                                  cancellable,
                                  copy_cb,
                                  &data);
+      serial = g_dbus_connection_get_last_serial (connection);
       g_main_loop_run (data.loop);
       res = gvfs_dbus_mount_call_pull_finish (proxy, data.res, &my_error);
     }
@@ -2975,8 +2981,12 @@ retry:
 
   if (! res)
     {
-      if (proxy && g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
-        _g_dbus_send_cancelled_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (proxy)));
+      if (serial != 0 &&
+          g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        {
+          _g_dbus_send_cancelled_with_serial_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (proxy)),
+                                                   serial);
+        }
       else
       if (g_error_matches (my_error, G_VFS_ERROR, G_VFS_ERROR_RETRY))
         {
diff --git a/client/gvfsdaemondbus.c b/client/gvfsdaemondbus.c
index dc5f50f..0bf47b1 100644
--- a/client/gvfsdaemondbus.c
+++ b/client/gvfsdaemondbus.c
@@ -418,14 +418,12 @@ _g_dbus_async_unsubscribe_cancellable (GCancellable *cancellable, gulong cancell
 }
 
 void
- _g_dbus_send_cancelled_sync (GDBusConnection *connection)
+_g_dbus_send_cancelled_with_serial_sync (GDBusConnection *connection,
+                                         guint32 serial)
 {
-  guint32 serial;
   GVfsDBusDaemon *proxy;
   GError *error = NULL;
 
-  serial = g_dbus_connection_get_last_serial (connection);
-
   proxy = gvfs_dbus_daemon_proxy_new_sync (connection,
                                            G_DBUS_PROXY_FLAGS_NONE,
                                            NULL,
@@ -448,6 +446,13 @@ void
   g_object_unref (proxy);
 }
 
+void
+_g_dbus_send_cancelled_sync (GDBusConnection *connection)
+{
+  _g_dbus_send_cancelled_with_serial_sync (connection,
+                                           g_dbus_connection_get_last_serial (connection));
+}
+
 
 /*************************************************************************
  *               get per-thread synchronous dbus connections             *
diff --git a/client/gvfsdaemondbus.h b/client/gvfsdaemondbus.h
index 24f5056..bd02d41 100644
--- a/client/gvfsdaemondbus.h
+++ b/client/gvfsdaemondbus.h
@@ -67,6 +67,8 @@ gulong          _g_dbus_async_subscribe_cancellable     (GDBusConnection
 void            _g_dbus_async_unsubscribe_cancellable   (GCancellable                   *cancellable,
                                                          gulong                          cancelled_tag);
 void            _g_dbus_send_cancelled_sync             (GDBusConnection                *connection);
+void            _g_dbus_send_cancelled_with_serial_sync (GDBusConnection                *connection,
+                                                         guint32                         serial);
 void            _g_propagate_error_stripped             (GError                        **dest,
                                                          GError                         *src);
 G_END_DECLS


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