[tracker/class-signal: 47/61] tracker-store, libtracker-data: Resetting of events on rollback and etc



commit 13c34d7ee00ab45e743b69af2f685e801c38c1ef
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Aug 27 13:19:32 2010 +0200

    tracker-store, libtracker-data: Resetting of events on rollback and etc

 src/libtracker-data/tracker-class.c   |   20 +++++++++++++++++++-
 src/libtracker-data/tracker-class.h   |    3 ++-
 src/tracker-store/tracker-events.c    |   19 +++++++++++--------
 src/tracker-store/tracker-events.h    |    2 +-
 src/tracker-store/tracker-resources.c |   10 +++++-----
 src/tracker-store/tracker-store.c     |    2 +-
 src/tracker-store/tracker-writeback.c |   18 +++++++++++++++++-
 src/tracker-store/tracker-writeback.h |   28 +++++++++++++++-------------
 8 files changed, 71 insertions(+), 31 deletions(-)
---
diff --git a/src/libtracker-data/tracker-class.c b/src/libtracker-data/tracker-class.c
index f78c6d9..a4ac1db 100644
--- a/src/libtracker-data/tracker-class.c
+++ b/src/libtracker-data/tracker-class.c
@@ -521,7 +521,7 @@ tracker_class_foreach_delete_event (TrackerClass        *class,
 }
 
 void
-tracker_class_reset_events (TrackerClass *class)
+tracker_class_reset_ready_events (TrackerClass *class)
 {
 	TrackerClassPrivate *priv;
 
@@ -539,6 +539,24 @@ tracker_class_reset_events (TrackerClass *class)
 }
 
 void
+tracker_class_reset_pending_events (TrackerClass *class)
+{
+	TrackerClassPrivate *priv;
+
+	g_return_if_fail (TRACKER_IS_CLASS (class));
+
+	priv = GET_PRIV (class);
+
+	/* Reset */
+	g_array_set_size (priv->deletes.pending.sub_pred_ids, 0);
+	g_array_set_size (priv->deletes.pending.object_ids, 0);
+
+	g_array_set_size (priv->inserts.pending.sub_pred_ids, 0);
+	g_array_set_size (priv->inserts.pending.object_ids, 0);
+
+}
+
+void
 tracker_class_transact_events (TrackerClass *class)
 {
 	TrackerClassPrivate *priv;
diff --git a/src/libtracker-data/tracker-class.h b/src/libtracker-data/tracker-class.h
index 261dab8..2bc90a1 100644
--- a/src/libtracker-data/tracker-class.h
+++ b/src/libtracker-data/tracker-class.h
@@ -98,7 +98,8 @@ void              tracker_class_foreach_insert_event   (TrackerClass        *cla
                                                         gpointer             user_data);
 gboolean          tracker_class_has_insert_events      (TrackerClass        *class);
 gboolean          tracker_class_has_delete_events      (TrackerClass        *class);
-void              tracker_class_reset_events           (TrackerClass        *class);
+void              tracker_class_reset_ready_events     (TrackerClass        *class);
+void              tracker_class_reset_pending_events   (TrackerClass        *class);
 void              tracker_class_transact_events        (TrackerClass        *class);
 void              tracker_class_add_delete_event       (TrackerClass        *class,
                                                         gint                 subject_id,
diff --git a/src/tracker-store/tracker-events.c b/src/tracker-store/tracker-events.c
index 2ce7bf8..8de62af 100644
--- a/src/tracker-store/tracker-events.c
+++ b/src/tracker-store/tracker-events.c
@@ -188,22 +188,21 @@ tracker_events_add_delete (gint         graph_id,
 }
 
 void
-tracker_events_reset (void)
+tracker_events_reset_pending (void)
 {
-/*	GHashTableIter iter;
-	gpointer key, value; */
+	GHashTableIter iter;
+	gpointer key, value;
 
 	g_return_if_fail (private != NULL);
-/*
-	 this is wrong atm, check tracker-store.c what the purpose of this is
+
 	g_hash_table_iter_init (&iter, private->allowances);
 
 	while (g_hash_table_iter_next (&iter, &key, &value)) {
 		TrackerClass *class = key;
 
-		tracker_class_reset_events (class);
+		tracker_class_reset_pending_events (class);
 	}
-*/
+
 	private->frozen = FALSE;
 }
 
@@ -226,7 +225,11 @@ free_private (EventsPrivate *private)
 	while (g_hash_table_iter_next (&iter, &key, &value)) {
 		TrackerClass *class = key;
 
-		tracker_class_reset_events (class);
+		/* Perhaps hurry an emit of the ready events here? We're shutting down,
+		 * so I guess we're not required to do that here ... ? */
+		tracker_class_reset_ready_events (class);
+
+		tracker_class_reset_pending_events (class);
 	}
 
 	g_hash_table_unref (private->allowances);
diff --git a/src/tracker-store/tracker-events.h b/src/tracker-store/tracker-events.h
index 2dc9acd..74cbd39 100644
--- a/src/tracker-store/tracker-events.h
+++ b/src/tracker-store/tracker-events.h
@@ -48,7 +48,7 @@ void       tracker_events_add_delete        (gint                      graph_id,
                                              GPtrArray                *rdf_types);
 void       tracker_events_classes_iter      (GHashTableIter           *iter);
 guint      tracker_events_get_total         (gboolean                  and_reset);
-void       tracker_events_reset             (void);
+void       tracker_events_reset_pending     (void);
 void       tracker_events_freeze            (void);
 
 G_END_DECLS
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index e7eb4a3..361a1b2 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -589,7 +589,7 @@ emit_class_signal (TrackerResources *self,
 
 		dbus_message_unref (message);
 
-		tracker_class_reset_events (class);
+		tracker_class_reset_ready_events (class);
 
 		return TRUE;
 	}
@@ -624,14 +624,14 @@ on_emit_class_signal (gpointer user_data)
 
 
 	/* Writeback feature */
-	writebacks = tracker_writeback_get_pending ();
+	writebacks = tracker_writeback_get_ready ();
 
 	if (writebacks) {
 		had_any = TRUE;
 		g_signal_emit (resources, signals[WRITEBACK], 0, writebacks);
 	}
 
-	tracker_writeback_reset ();
+	tracker_writeback_reset_ready ();
 
 	if (!had_any)
 		priv->class_signal_timeout = 0;
@@ -667,8 +667,8 @@ on_statements_committed (gpointer user_data)
 static void
 on_statements_rolled_back (gpointer user_data)
 {
-	tracker_events_reset ();
-	tracker_writeback_reset ();
+	tracker_events_reset_pending ();
+	tracker_writeback_reset_pending ();
 }
 
 static void
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 824e99b..7d10695 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -380,7 +380,7 @@ pool_dispatch_cb (gpointer data,
 
 		tracker_events_freeze ();
 		tracker_data_load_turtle_file (file, &task->error);
-		tracker_events_reset ();
+		tracker_events_reset_pending ();
 
 		g_object_unref (file);
 	}
diff --git a/src/tracker-store/tracker-writeback.c b/src/tracker-store/tracker-writeback.c
index f0bb8bb..6090831 100644
--- a/src/tracker-store/tracker-writeback.c
+++ b/src/tracker-store/tracker-writeback.c
@@ -117,8 +117,24 @@ tracker_writeback_reset (void)
 	}
 }
 
+void
+tracker_writeback_reset_pending ()
+{
+	g_return_if_fail (private != NULL);
+
+	g_hash_table_remove_all (private->pending_events);
+}
+
+void
+tracker_writeback_reset_ready ()
+{
+	g_return_if_fail (private != NULL);
+
+	g_hash_table_remove_all (private->ready_events);
+}
+
 GHashTable *
-tracker_writeback_get_pending (void)
+tracker_writeback_get_ready (void)
 {
 	g_return_val_if_fail (private != NULL, NULL);
 
diff --git a/src/tracker-store/tracker-writeback.h b/src/tracker-store/tracker-writeback.h
index b141665..b52842e 100644
--- a/src/tracker-store/tracker-writeback.h
+++ b/src/tracker-store/tracker-writeback.h
@@ -29,19 +29,21 @@ G_BEGIN_DECLS
 
 typedef GStrv (*TrackerWritebackGetPredicatesFunc) (void);
 
-void        tracker_writeback_init        (TrackerWritebackGetPredicatesFunc callback);
-void        tracker_writeback_shutdown    (void);
-void        tracker_writeback_check       (gint         graph_id,
-                                           const gchar *graph,
-                                           gint         subject_id,
-                                           const gchar *subject,
-                                           gint         pred_id,
-                                           gint         object_id,
-                                           const gchar *object,
-                                           GPtrArray   *rdf_types);
-GHashTable* tracker_writeback_get_pending (void);
-void        tracker_writeback_reset       (void);
-void        tracker_writeback_transact    (void);
+void        tracker_writeback_init          (TrackerWritebackGetPredicatesFunc callback);
+void        tracker_writeback_shutdown      (void);
+void        tracker_writeback_check         (gint         graph_id,
+                                             const gchar *graph,
+                                             gint         subject_id,
+                                             const gchar *subject,
+                                             gint         pred_id,
+                                             gint         object_id,
+                                             const gchar *object,
+                                             GPtrArray   *rdf_types);
+GHashTable* tracker_writeback_get_ready     (void);
+void        tracker_writeback_reset_pending (void);
+void        tracker_writeback_reset_ready   (void);
+void        tracker_writeback_reset         (void);
+void        tracker_writeback_transact      (void);
 
 G_END_DECLS
 



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