diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2013-12-08 12:28:55 +0200 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-11-18 06:24:12 +0000 |
commit | a336ef412ace2f9fc169185c48bca657e28c646e (patch) | |
tree | 81dba0195f14dc49f002d8a55382d0f920226306 | |
parent | 14032ee48bab618e9e7c75134f1c653e996bc4dd (diff) | |
download | gvfs-a336ef412ace2f9fc169185c48bca657e28c646e.tar.gz |
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
-rw-r--r-- | client/gdaemonfile.c | 14 | ||||
-rw-r--r-- | client/gvfsdaemondbus.c | 13 | ||||
-rw-r--r-- | client/gvfsdaemondbus.h | 2 |
3 files changed, 23 insertions, 6 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c index cff031b7..e97c9a4e 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 dc5f50ff..0bf47b1f 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 24f50568..bd02d417 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 |