[tracker/dbus-fd-experiment] Steroids: drop RC codes and rely on pipe closing



commit 63645e7ad69289860433369a5251ba1503c1b5b7
Author: Adrien Bustany <abustany gnome org>
Date:   Tue Jun 15 10:30:47 2010 -0400

    Steroids: drop RC codes and rely on pipe closing

 src/libtracker-client/tracker.c      |   55 ++++++---------------------------
 src/tracker-store/tracker-steroids.c |   16 ----------
 src/tracker-store/tracker-steroids.h |    4 --
 3 files changed, 10 insertions(+), 65 deletions(-)
---
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index 2265b5e..9d7a141 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -160,7 +160,6 @@ typedef struct {
 
 struct TrackerResultIterator {
 #ifdef HAVE_DBUS_FD_PASSING
-	int rc;
 	char *buffer;
 	int buffer_index;
 	long buffer_size;
@@ -168,7 +167,6 @@ struct TrackerResultIterator {
 	guint  n_columns;
 	int   *offsets;
 	char  *data;
-	gboolean has_next;
 #else
 	GPtrArray *results;
 	gint current_row;
@@ -543,15 +541,10 @@ fast_async_callback_iterator (GObject      *source_object,
 	}
 
 	iterator->buffer_index = 0;
-	iterator->rc = iterator_buffer_read_int (iterator);
 
 	/* Reset the iterator internal state */
 	iterator->buffer_index = 0;
 
-	if (iterator->rc == TRACKER_STEROIDS_RC_ROW) {
-		iterator->has_next = TRUE;
-	}
-
 	dbus_pending_call_block (data->dbus_call);
 
 	reply = dbus_pending_call_steal_reply (data->dbus_call);
@@ -1642,14 +1635,6 @@ tracker_resources_sparql_query_iterate (TrackerClient  *client,
 	}
 
 	iterator->buffer_index = 0;
-	iterator->rc = iterator_buffer_read_int (iterator);
-
-	/* Reset the iterator internal state */
-	iterator->buffer_index = 0;
-
-	if (iterator->rc == TRACKER_STEROIDS_RC_ROW) {
-		iterator->has_next = TRUE;
-	}
 
 	dbus_pending_call_block (call);
 
@@ -1768,7 +1753,7 @@ tracker_result_iterator_has_next (TrackerResultIterator *iterator)
 #ifdef HAVE_DBUS_FD_PASSING
 	g_return_val_if_fail (iterator, FALSE);
 
-	return iterator->has_next;
+	return iterator->buffer_index < iterator->buffer_size;
 #else
 	g_return_val_if_fail (iterator, FALSE);
 
@@ -1792,38 +1777,18 @@ void
 tracker_result_iterator_next (TrackerResultIterator  *iterator)
 {
 #ifdef HAVE_DBUS_FD_PASSING
-	int nextrc;
 	int last_offset;
 
-	iterator->rc = iterator_buffer_read_int (iterator);
-	switch (iterator->rc) {
-	case TRACKER_STEROIDS_RC_ROW:
-		iterator->n_columns = iterator_buffer_read_int (iterator);
-		iterator->offsets = (int *)(iterator->buffer + iterator->buffer_index);
-		iterator->buffer_index += sizeof (int) * (iterator->n_columns - 1);
-		last_offset = iterator_buffer_read_int (iterator);
-		iterator->data = iterator->buffer + iterator->buffer_index;
-		iterator->buffer_index += last_offset + 1;
-
-		nextrc = iterator_buffer_read_int (iterator);
-		iterator->buffer_index -= 4;
-
-		if (nextrc == TRACKER_STEROIDS_RC_ROW) {
-			iterator->has_next = TRUE;
-		} else if (nextrc == TRACKER_STEROIDS_RC_DONE) {
-			iterator->has_next = FALSE;
-		} else {
-			g_critical ("Invalid row code %d", nextrc);
-			iterator->has_next = FALSE;
-		}
-		break;
-	case TRACKER_STEROIDS_RC_DONE:
-		break;
-	default:
-		/* If an error happened, it has been reported by
-		 * tracker_resources_sparql_query_iterate */
-		break;
+	if (!tracker_result_iterator_has_next (iterator)) {
+		return;
 	}
+
+	iterator->n_columns = iterator_buffer_read_int (iterator);
+	iterator->offsets = (int *)(iterator->buffer + iterator->buffer_index);
+	iterator->buffer_index += sizeof (int) * (iterator->n_columns - 1);
+	last_offset = iterator_buffer_read_int (iterator);
+	iterator->data = iterator->buffer + iterator->buffer_index;
+	iterator->buffer_index += last_offset + 1;
 #else
 	g_return_if_fail (iterator);
 
diff --git a/src/tracker-store/tracker-steroids.c b/src/tracker-store/tracker-steroids.c
index a0f94b7..333fa98 100644
--- a/src/tracker-store/tracker-steroids.c
+++ b/src/tracker-store/tracker-steroids.c
@@ -258,10 +258,6 @@ query_inthread (TrackerDBCursor *cursor,
 	data_output_stream = g_data_output_stream_new (output_stream);
 
 	if (error) {
-		g_data_output_stream_put_int32 (data_output_stream,
-		                                TRACKER_STEROIDS_RC_ERROR,
-		                                NULL,
-		                                NULL);
 		g_object_unref (data_output_stream);
 		g_object_unref (output_stream);
 		g_object_unref (unix_output_stream);
@@ -295,11 +291,6 @@ query_inthread (TrackerDBCursor *cursor,
 			column_offsets[i] = last_offset;
 		}
 
-		g_data_output_stream_put_int32 (data_output_stream,
-		                                TRACKER_STEROIDS_RC_ROW,
-		                                NULL,
-		                                &loop_error);
-
 		if (loop_error) {
 			goto end_query_inthread;
 		}
@@ -345,13 +336,6 @@ query_inthread (TrackerDBCursor *cursor,
 	}
 end_query_inthread:
 
-	if (!loop_error) {
-		g_data_output_stream_put_int32 (data_output_stream,
-		                                TRACKER_STEROIDS_RC_DONE,
-		                                NULL,
-		                                &loop_error);
-	}
-
 	/* Will force flushing */
 	g_object_unref (data_output_stream);
 	g_object_unref (output_stream);
diff --git a/src/tracker-store/tracker-steroids.h b/src/tracker-store/tracker-steroids.h
index c7bb1e1..3cdb6c4 100644
--- a/src/tracker-store/tracker-steroids.h
+++ b/src/tracker-store/tracker-steroids.h
@@ -37,10 +37,6 @@ G_BEGIN_DECLS
 
 #define TRACKER_STEROIDS_BUFFER_SIZE 65536
 
-#define TRACKER_STEROIDS_RC_ERROR 0
-#define TRACKER_STEROIDS_RC_ROW   1
-#define TRACKER_STEROIDS_RC_DONE  2
-
 typedef struct TrackerSteroids      TrackerSteroids;
 typedef struct TrackerSteroidsClass TrackerSteroidsClass;
 



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