[tracker/direct-access-update-fd-passing] Add support for cancel, squash



commit 1789233258fce5c46748964cdc2be312b97fb4a6
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Jul 21 14:01:53 2010 +0200

    Add support for cancel, squash

 src/libtracker-bus/tracker-bus-fd-update.c |   55 ++++++++++++++++++----------
 1 files changed, 35 insertions(+), 20 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus-fd-update.c b/src/libtracker-bus/tracker-bus-fd-update.c
index 7decd63..7ac2f44 100644
--- a/src/libtracker-bus/tracker-bus-fd-update.c
+++ b/src/libtracker-bus/tracker-bus-fd-update.c
@@ -38,7 +38,6 @@
 #ifdef HAVE_DBUS_FD_PASSING
 
 /* Are also defined in src/tracker-store/tracker-steroids.h */
-#define TRACKER_STEROIDS_BUFFER_SIZE      65536
 
 typedef enum {
 	FAST_UPDATE,
@@ -52,25 +51,9 @@ typedef struct {
 	DBusPendingCall *dbus_call;
 	GSimpleAsyncResult *res;
 	gpointer user_data;
+	gulong cancelid;
 } FastAsyncData;
 
-static FastAsyncData *
-fast_async_data_new (DBusConnection    *connection,
-                     FastOperationType  operation_type,
-                     GCancellable      *cancellable,
-                     gpointer           user_data)
-{
-	FastAsyncData *data;
-
-	data = g_slice_new0 (FastAsyncData);
-
-	data->connection = dbus_connection_ref (connection);
-	data->operation_type = operation_type;
-	data->cancellable = cancellable;
-	data->user_data = user_data;
-
-	return data;
-}
 
 static void
 fast_async_data_free (gpointer data)
@@ -94,6 +77,39 @@ fast_async_data_free (gpointer data)
 	}
 }
 
+static void
+on_cancel (FastAsyncData *fad)
+{
+	if (fad->dbus_call) {
+		dbus_pending_call_cancel (fad->dbus_call);
+		dbus_pending_call_unref (fad->dbus_call);
+		fad->dbus_call = NULL;
+	}
+
+	fast_async_data_free (fad);
+}
+
+static FastAsyncData *
+fast_async_data_new (DBusConnection    *connection,
+                     FastOperationType  operation_type,
+                     GCancellable      *cancellable,
+                     gpointer           user_data)
+{
+	FastAsyncData *data;
+
+	data = g_slice_new0 (FastAsyncData);
+
+	data->connection = dbus_connection_ref (connection);
+	data->operation_type = operation_type;
+	data->cancellable = g_object_ref (cancellable);
+	data->user_data = user_data;
+
+	data->cancelid = g_cancellable_connect (cancellable, G_CALLBACK (on_cancel), data, NULL);
+
+	return data;
+}
+
+
 static GHashTable *
 unmarshal_hash_table (DBusMessageIter *iter)
 {
@@ -258,7 +274,7 @@ sparql_update_fast_send (DBusConnection     *connection,
 
 	output_stream = g_unix_output_stream_new (pipefd[1], TRUE);
 	buffered_output_stream = g_buffered_output_stream_new_sized (output_stream,
-	                                                             TRACKER_STEROIDS_BUFFER_SIZE);
+	                                                             TRACKER_DBUS_PIPE_BUFFER_SIZE);
 	data_output_stream = g_data_output_stream_new (buffered_output_stream);
 
 	g_data_output_stream_put_int32 (data_output_stream, strlen (query),
@@ -486,7 +502,6 @@ tracker_bus_fd_sparql_update_blank_async (DBusGConnection       *connection,
 	                           FAST_UPDATE_BLANK,
 	                           cancellable,
 	                           user_data);
-	
 
 	fad->res = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
 	                                      tracker_bus_fd_sparql_update_blank_async);



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