diff options
author | Benjamin Otte <otte@gnome.org> | 2009-06-25 13:01:48 +0200 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2009-06-25 13:01:48 +0200 |
commit | c372064a04f8c24efdb99a3b0811bd17ddfb2176 (patch) | |
tree | 61906e539114b76be2d7c82c384688f50bada002 /client/gvfsiconloadable.c | |
parent | 133bd0ec75a94b8316b56c252dfc62a3ed23fade (diff) | |
download | gvfs-c372064a04f8c24efdb99a3b0811bd17ddfb2176.tar.gz |
try extra hard to make sure operations get cancelled properly
Previously there were some rather big windows that allowed for races
between cancelling and calling g_simple_async_result_complete().
This code makes sure we check for cancellaton right before calling
g_simple_async_result_complete(), which gets rid of that window and
gives you the guarantee that cancelling an operation in the main thread
will indeed return a CANCELLED error.
Diffstat (limited to 'client/gvfsiconloadable.c')
-rw-r--r-- | client/gvfsiconloadable.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/client/gvfsiconloadable.c b/client/gvfsiconloadable.c index 1c6d54b4..28251cf0 100644 --- a/client/gvfsiconloadable.c +++ b/client/gvfsiconloadable.c @@ -208,7 +208,7 @@ async_path_call_done (DBusMessage *reply, if (io_error != NULL) { g_simple_async_result_set_from_error (data->result, io_error); - g_simple_async_result_complete (data->result); + _g_simple_async_result_complete_with_cancellable (data->result, data->cancellable); async_path_call_free (data); } else @@ -239,7 +239,7 @@ do_async_path_call_callback (GMountInfo *mount_info, if (error != NULL) { g_simple_async_result_set_from_error (data->result, error); - g_simple_async_result_complete (data->result); + _g_simple_async_result_complete_with_cancellable (data->result, data->cancellable); async_path_call_free (data); return; } @@ -321,6 +321,7 @@ do_async_path_call (GVfsIcon *vfs_icon, typedef struct { GSimpleAsyncResult *result; + GCancellable *cancellable; gboolean can_seek; } GetFDData; @@ -343,9 +344,12 @@ load_async_get_fd_cb (int fd, g_simple_async_result_set_op_res_gpointer (data->result, stream, g_object_unref); } - g_simple_async_result_complete (data->result); + _g_simple_async_result_complete_with_cancellable (data->result, + data->cancellable); g_object_unref (data->result); + if (data->cancellable) + g_object_unref (data->cancellable); g_free (data); } @@ -368,12 +372,14 @@ load_async_cb (DBusMessage *reply, g_simple_async_result_set_error (result, G_IO_ERROR, G_IO_ERROR_FAILED, _("Invalid return value from open")); - g_simple_async_result_complete (result); + _g_simple_async_result_complete_with_cancellable (result, cancellable); return; } get_fd_data = g_new0 (GetFDData, 1); get_fd_data->result = g_object_ref (result); + if (cancellable) + get_fd_data->cancellable = g_object_ref (cancellable); get_fd_data->can_seek = can_seek; _g_dbus_connection_get_fd_async (connection, fd_id, |