[tracker/gdbus-porting: 50/65] Fixes deathlock



commit 909889a6ff8fb5f1ce504333447c8b4718565da6
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Jan 5 11:32:33 2011 +0100

    Fixes deathlock

 src/libtracker-common/tracker-dbus.c |   62 ++++++++++++++++------------------
 1 files changed, 29 insertions(+), 33 deletions(-)
---
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index 581ded4..17c63fc 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -645,18 +645,33 @@ 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 */
@@ -699,34 +714,6 @@ send_and_splice_async_callback (GObject      *source,
 }
 
 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,
                                 gpointer      user_data)
@@ -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;
 }



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