Commit 90381ecd authored by Dan Winship's avatar Dan Winship

Use low-level GSource methods in a few more places

(in preparation for thread-default context support)
parent 28a39fab
......@@ -77,7 +77,7 @@ struct _GFileMonitorPrivate {
/* Rate limiting change events */
GHashTable *rate_limiter;
guint pending_file_change_id;
GSource *pending_file_change_source;
GSList *pending_file_changes; /* FileChange */
GSource *timeout;
......@@ -181,10 +181,11 @@ g_file_monitor_dispose (GObject *object)
monitor = G_FILE_MONITOR (object);
priv = monitor->priv;
if (priv->pending_file_change_id)
if (priv->pending_file_change_source)
{
g_source_remove (priv->pending_file_change_id);
priv->pending_file_change_id = 0;
g_source_destroy (priv->pending_file_change_source);
g_source_unref (priv->pending_file_change_source);
priv->pending_file_change_source = NULL;
}
g_slist_foreach (priv->pending_file_changes, (GFunc) file_change_free, NULL);
g_slist_free (priv->pending_file_changes);
......@@ -362,7 +363,11 @@ emit_cb (gpointer data)
pending = g_slist_reverse (monitor->priv->pending_file_changes);
monitor->priv->pending_file_changes = NULL;
monitor->priv->pending_file_change_id = 0;
if (monitor->priv->pending_file_change_source)
{
g_source_unref (monitor->priv->pending_file_change_source);
monitor->priv->pending_file_change_source = NULL;
}
g_object_ref (monitor);
for (iter = pending; iter; iter = iter->next)
......@@ -399,17 +404,17 @@ emit_in_idle (GFileMonitor *monitor,
change->other_file = NULL;
change->event_type = event_type;
if (!priv->pending_file_change_id)
if (!priv->pending_file_change_source)
{
source = g_idle_source_new ();
priv->pending_file_change_source = source;
g_source_set_priority (source, 0);
/* We don't ref here - instead dispose will free any
/* We don't ref monitor here - instead dispose will free any
* pending idles.
*/
g_source_set_callback (source, emit_cb, monitor, NULL);
priv->pending_file_change_id = g_source_attach (source, NULL);
g_source_unref (source);
g_source_attach (source, NULL);
}
/* We reverse this in the processor */
priv->pending_file_changes = g_slist_prepend (priv->pending_file_changes, change);
......
......@@ -240,7 +240,7 @@ typedef struct {
GCancellable *cancellable;
int error_fd;
GIOChannel *error_channel;
guint error_channel_source_id;
GSource *error_channel_source;
GString *error_string;
gchar **argv;
} UnmountEjectOp;
......@@ -274,7 +274,11 @@ eject_unmount_cb (GPid pid, gint status, gpointer user_data)
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_source_remove (data->error_channel_source_id);
if (data->error_channel_source)
{
g_source_destroy (data->error_channel_source);
g_source_unref (data->error_channel_source);
}
g_io_channel_unref (data->error_channel);
g_string_free (data->error_string, TRUE);
g_strfreev (data->argv);
......@@ -312,6 +316,12 @@ read:
g_string_append (data->error_string, error->message);
g_error_free (error);
if (data->error_channel_source)
{
g_source_unref (data->error_channel_source);
data->error_channel_source = NULL;
}
return FALSE;
}
......@@ -323,6 +333,7 @@ eject_unmount_do_cb (gpointer user_data)
{
UnmountEjectOp *data = (UnmountEjectOp *) user_data;
GPid child_pid;
GSource *child_watch;
GError *error = NULL;
if (!g_spawn_async_with_pipes (NULL, /* working dir */
......@@ -347,8 +358,15 @@ eject_unmount_do_cb (gpointer user_data)
if (error != NULL)
goto handle_error;
data->error_channel_source_id = g_io_add_watch (data->error_channel, G_IO_IN, eject_unmount_read_error, data);
g_child_watch_add (child_pid, eject_unmount_cb, data);
data->error_channel_source = g_io_create_watch (data->error_channel, G_IO_IN);
g_source_set_callback (data->error_channel_source,
(GSourceFunc) eject_unmount_read_error, data, NULL);
g_source_attach (data->error_channel_source, NULL);
child_watch = g_child_watch_source_new (child_pid);
g_source_set_callback (child_watch, (GSourceFunc) eject_unmount_cb, data, NULL);
g_source_attach (child_watch, NULL);
g_source_unref (child_watch);
handle_error:
if (error != NULL) {
......
......@@ -289,7 +289,7 @@ typedef struct {
GCancellable *cancellable;
int error_fd;
GIOChannel *error_channel;
guint error_channel_source_id;
GSource *error_channel_source;
GString *error_string;
} EjectMountOp;
......@@ -322,7 +322,11 @@ eject_mount_cb (GPid pid, gint status, gpointer user_data)
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_source_remove (data->error_channel_source_id);
if (data->error_channel_source)
{
g_source_destroy (data->error_channel_source);
g_source_unref (data->error_channel_source);
}
g_io_channel_unref (data->error_channel);
g_string_free (data->error_string, TRUE);
close (data->error_fd);
......@@ -359,6 +363,12 @@ read:
g_string_append (data->error_string, error->message);
g_error_free (error);
if (data->error_channel_source)
{
g_source_unref (data->error_channel_source);
data->error_channel_source = NULL;
}
return FALSE;
}
......@@ -375,6 +385,7 @@ eject_mount_do (GVolume *volume,
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
EjectMountOp *data;
GPid child_pid;
GSource *child_watch;
GError *error;
data = g_new0 (EjectMountOp, 1);
......@@ -406,8 +417,15 @@ eject_mount_do (GVolume *volume,
if (error != NULL)
goto handle_error;
data->error_channel_source_id = g_io_add_watch (data->error_channel, G_IO_IN, eject_mount_read_error, data);
g_child_watch_add (child_pid, eject_mount_cb, data);
data->error_channel_source = g_io_create_watch (data->error_channel, G_IO_IN);
g_source_set_callback (data->error_channel_source,
(GSourceFunc) eject_mount_read_error, data, NULL);
g_source_attach (data->error_channel_source, NULL);
child_watch = g_child_watch_source_new (child_pid);
g_source_set_callback (child_watch, (GSourceFunc) eject_mount_cb, data, NULL);
g_source_attach (child_watch, NULL);
g_source_unref (child_watch);
handle_error:
if (error != NULL) {
......
......@@ -95,7 +95,7 @@ struct GWin32ResolverRequest {
HANDLE *event;
GSimpleAsyncResult *async_result;
gboolean complete;
guint cancelled_idle;
GSource *cancelled_idle;
union {
struct {
......@@ -167,8 +167,9 @@ request_completed (gpointer user_data)
/* Clean up cancellation-related stuff first */
if (req->cancelled_idle)
{
g_source_remove (req->cancelled_idle);
req->cancelled_idle = 0;
g_source_destroy (req->cancelled_idle);
g_source_unref (req->cancelled_idle);
req->cancelled_idle = NULL;
}
if (req->cancellable)
{
......@@ -197,7 +198,8 @@ request_cancelled_idle (gpointer user_data)
GWin32ResolverRequest *req = user_data;
GError *error = NULL;
req->cancelled_idle = 0;
g_source_unref (req->cancelled_idle);
req->cancelled_idle = NULL;
g_cancellable_set_error_if_cancelled (req->cancellable, &error);
g_simple_async_result_set_from_error (req->async_result, error);
......@@ -226,9 +228,13 @@ request_cancelled (GCancellable *cancellable,
/* We need to wait until main-loop-time to actually complete the
* result; we don't use _complete_in_idle() here because we need to
* keep track of the source id.
* keep track of the source so we can potentially cancel it before
* it runs.
*/
req->cancelled_idle = g_idle_add (request_cancelled_idle, req);
req->cancelled_idle = g_idle_source_new ();
g_source_set_callback (req->cancelled_idle,
(GSourceFunc)request_cancelled_idle, req, NULL);
g_source_attach (req->cancelled_idle, NULL);
}
static DWORD WINAPI
......
......@@ -9,7 +9,7 @@ if ! which readelf 2>/dev/null >/dev/null; then
exit 0
fi
SKIP='\<g_access\|\<g_array_\|\<g_ascii\|\<g_list_\|\<g_assertion_message\|\<g_warn_message\|\<g_atomic\|\<g_bit_\|\<g_boxed\|\<g_build_filename\|\<g_byte_array\|\<g_checksum\|\<g_child_watch\|\<g_clear_error\|\<g_convert\|\<g_dir_\|\<g_enum_\|\<g_error_\|\<g_prefix_error\|\<g_file_error_quark\|\<g_file_get_contents\|\<g_file_set_contents\|\<g_file_test\|\<g_file_read_link\|\<g_filename_\|\<g_find_program_in_path\|\<g_flags_\|\<g_free\|\<g_get_\|\<g_getenv\|\<g_setenv\|\<g_hash_table_\|\<g_hostname_\|\<g_idle_\|\<g_intern_static_string\|\<g_io_add_watch\|\<g_io_channel_\|\<g_key_file_\|\<g_listenv\|\<g_locale_to_utf8\|\<g_log\|\<g_main_context_\|\<g_main_loop_\|\<g_malloc\|\<g_markup_\|\<g_mkdir_\|\<g_mkstemp\|\<g_module_\|\<g_object_\|\<g_once_\|\<g_param_spec_\|\<g_path_\|\<g_poll\|\<g_printerr\|\<g_propagate_error\|\<g_ptr_array_\|\<g_qsort_\|\<g_quark_\|\<g_queue_\|\<g_random_int_range\|\<g_realloc\|\<g_return_if_fail\|\<g_set_error\|\<g_shell_\|\<g_signal_\|\<g_slice_\|\<g_slist_\|\<g_snprintf\|\<g_source_\|\<g_spawn_\|\<g_static_\|\<g_str\|\<g_thread_pool_\|\<g_time_val_add\|\<g_timeout_\|\<g_type_\|\<g_unlink\|\<g_uri_\|\<g_utf8_\|\<g_value_'
SKIP='\<g_access\|\<g_array_\|\<g_ascii\|\<g_list_\|\<g_assertion_message\|\<g_warn_message\|\<g_atomic\|\<g_bit_\|\<g_boxed\|\<g_build_filename\|\<g_byte_array\|\<g_checksum\|\<g_child_watch\|\<g_clear_error\|\<g_convert\|\<g_dir_\|\<g_enum_\|\<g_error_\|\<g_prefix_error\|\<g_file_error_quark\|\<g_file_get_contents\|\<g_file_set_contents\|\<g_file_test\|\<g_file_read_link\|\<g_filename_\|\<g_find_program_in_path\|\<g_flags_\|\<g_free\|\<g_get_\|\<g_getenv\|\<g_setenv\|\<g_hash_table_\|\<g_hostname_\|\<g_idle_\|\<g_intern_static_string\|\<g_io_add_watch\|\<g_io_channel_\|\<g_io_create_watch\|\<g_key_file_\|\<g_listenv\|\<g_locale_to_utf8\|\<g_log\|\<g_main_context_\|\<g_main_loop_\|\<g_malloc\|\<g_markup_\|\<g_mkdir_\|\<g_mkstemp\|\<g_module_\|\<g_object_\|\<g_once_\|\<g_param_spec_\|\<g_path_\|\<g_poll\|\<g_printerr\|\<g_propagate_error\|\<g_ptr_array_\|\<g_qsort_\|\<g_quark_\|\<g_queue_\|\<g_random_int_range\|\<g_realloc\|\<g_return_if_fail\|\<g_set_error\|\<g_shell_\|\<g_signal_\|\<g_slice_\|\<g_slist_\|\<g_snprintf\|\<g_source_\|\<g_spawn_\|\<g_static_\|\<g_str\|\<g_thread_pool_\|\<g_time_val_add\|\<g_timeout_\|\<g_type_\|\<g_unlink\|\<g_uri_\|\<g_utf8_\|\<g_value_'
for so in .libs/lib*.so; do
echo Checking $so for local PLT entries
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment