From 909889a6ff8fb5f1ce504333447c8b4718565da6 Mon Sep 17 00:00:00 2001 From: Philip Van Hoof Date: Wed, 5 Jan 2011 11:32:33 +0100 Subject: Fixes deathlock --- src/libtracker-common/tracker-dbus.c | 62 +++++++++++++++++------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c index 581ded4d6..17c63fcbc 100644 --- a/src/libtracker-common/tracker-dbus.c +++ b/src/libtracker-common/tracker-dbus.c @@ -644,19 +644,34 @@ static void send_and_splice_async_callback (GObject *source, GAsyncResult *result, gpointer user_data) +{ + GError *error = NULL; + + g_output_stream_splice_finish (G_OUTPUT_STREAM (source), result, &error); + + if (error) { + g_critical ("Error while splicing: %s", + error ? error->message : "Error not specified"); + g_error_free (error); + } +} + +static void +tracker_dbus_send_and_splice_async_finish (GObject *source, + GAsyncResult *result, + gpointer user_data) { SendAndSpliceData *data = user_data; GError *error = NULL; - g_output_stream_splice_finish (data->output_stream, - result, - &error); + data->reply = g_dbus_connection_send_message_with_reply_finish (G_DBUS_CONNECTION (source), + result, &error); - if (G_LIKELY (!error)) { + if (!error) { /* dbus_pending_call_block (data->call); reply = dbus_pending_call_steal_reply (data->call); */ - if (G_UNLIKELY (g_dbus_message_get_message_type (data->reply) == G_DBUS_MESSAGE_TYPE_ERROR)) { + if (g_dbus_message_get_message_type (data->reply) == G_DBUS_MESSAGE_TYPE_ERROR) { /* If any error happened, we're not passing any received data, so we * need to free it */ @@ -698,34 +713,6 @@ send_and_splice_async_callback (GObject *source, send_and_splice_data_free (data); } -static void -tracker_dbus_send_and_splice_async_finish (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - SendAndSpliceData *data = user_data; - GError *error = NULL; - - data->reply = g_dbus_connection_send_message_with_reply_finish ((GDBusConnection *) source, - result, &error); - - if (error) { - g_critical ("FD passing unsupported or connection disconnected: %s", - error ? error->message : "No error provided"); - g_error_free (error); - return; - } - - g_output_stream_splice_async (data->output_stream, - data->buffered_input_stream, - G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | - G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, - 0, - data->cancellable, - send_and_splice_async_callback, - data); -} - static void tracker_g_async_ready_callback (GObject *source_object, GAsyncResult *res, @@ -777,5 +764,14 @@ tracker_dbus_send_and_splice_async (GDBusConnection *connection tracker_dbus_send_and_splice_async_finish, user_data, NULL)); + g_output_stream_splice_async (data->output_stream, + data->buffered_input_stream, + G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | + G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, + 0, + data->cancellable, + send_and_splice_async_callback, + data); + return TRUE; } -- cgit v1.2.1