[tracker/tracker-0.6] Pause indexer when setting volume states & disable TTL use



commit 8bc294f4480a6b754a7b14d6d15c915a6d11727a
Author: Martyn Russell <martyn imendio com>
Date:   Wed May 13 11:10:24 2009 +0100

    Pause indexer when setting volume states & disable TTL use
    
    Disable udi variable check in tracker-data-update, was causing some
    log warnings when NULL is quite acceptable.
    
    Disabled TTL APIs (tracker_removable_device_*) in indexer which was
    causing several bugs related to speed and caching of albumart.
    
    Make sure we quit the main loop in the event we have NO volumes to
    enable on startup in the daemon.
    
    Make sure we pause the indexer before doing ANY volume calls to ensure
    they get through when the indexer is quite busy. Any failure response
    here will shutdown the daemon so this is quite important.
---
 src/libtracker-data/tracker-data-update.c |    1 -
 src/tracker-indexer/tracker-indexer.c     |   35 +++++++----
 src/trackerd/tracker-main.c               |   86 +++++++++++++++++++---------
 3 files changed, 80 insertions(+), 42 deletions(-)

diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index b686dee..e3f1fef 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -708,7 +708,6 @@ tracker_data_update_replace_service (const gchar *udi,
 	gboolean             set_metadata = FALSE;
 	guint32              id = 0;
 
-	g_return_if_fail (udi != NULL);
 	g_return_if_fail (path != NULL);
 	g_return_if_fail (metadata != NULL);
 
diff --git a/src/tracker-indexer/tracker-indexer.c b/src/tracker-indexer/tracker-indexer.c
index 053a324..eaec775 100644
--- a/src/tracker-indexer/tracker-indexer.c
+++ b/src/tracker-indexer/tracker-indexer.c
@@ -101,6 +101,8 @@
 #define METADATA_FILE_NAME	     "File:Name"
 #define METADATA_FILE_MIMETYPE       "File:Mime"
 
+#undef ENABLE_TTL_LOADER
+
 typedef struct PathInfo PathInfo;
 typedef struct MetadataForeachData MetadataForeachData;
 typedef struct MetadataRequest MetadataRequest;
@@ -1772,19 +1774,21 @@ item_add_or_update (TrackerIndexer        *indexer,
 				     basename, 
 				     NULL);
 
+#ifdef ENABLE_TTL_LOADER
 #ifdef HAVE_HAL
 	if (tracker_hal_path_is_on_removable_device (indexer->private->hal,
 						     service_path, 
 						     &mount_point,
 						     NULL)) {
-
 		tracker_removable_device_add_metadata (indexer, 
 						       mount_point, 
 						       service_path, 
 						       tracker_service_get_name (service),
 						       metadata);
 	}
-#endif
+#endif /* HAVE_HAL */
+#endif /* ENABLE_TTL_LOADER */
+
 	g_free (mount_point);
 	g_free (service_path);
 }
@@ -1845,6 +1849,8 @@ update_moved_item_removable_device (TrackerIndexer *indexer,
 				    GFile          *file,
 				    GFile          *source_file)
 {
+#ifdef ENABLE_TTL_LOADER
+#ifdef HAVE_HAL
 	const gchar *service_name;
 	gchar *path, *source_path;
 	gchar *mount_point = NULL;
@@ -1853,23 +1859,19 @@ update_moved_item_removable_device (TrackerIndexer *indexer,
 	path = g_file_get_path (file);
 	source_path = g_file_get_path (source_file);
 
-#ifdef HAVE_HAL
 	if (tracker_hal_path_is_on_removable_device (indexer->private->hal,
 						     source_path,
 						     &mount_point,
-						     NULL) ) {
-
+						     NULL)) {
 		if (tracker_hal_path_is_on_removable_device (indexer->private->hal,
-						     path,
-						     NULL,
-						     NULL) ) {
-
+							     path,
+							     NULL,
+							     NULL)) {
 			tracker_removable_device_add_move (indexer,
 							   mount_point,
 							   source_path,
 							   path,
 							   service_name);
-
 		} else {
 			tracker_removable_device_add_removal (indexer,
 							      mount_point,
@@ -1877,10 +1879,12 @@ update_moved_item_removable_device (TrackerIndexer *indexer,
 							      service_name);
 		}
 	}
-#endif
+
 	g_free (mount_point);
 	g_free (source_path);
 	g_free (path);
+#endif /* HAVE_HAL */
+#endif /* ENABLE_TTL_LOADER */
 }
 
 static void
@@ -2206,17 +2210,20 @@ item_mark_for_removal (TrackerIndexer *indexer,
 
 		g_hash_table_destroy (children);
 	}
+
+#ifdef ENABLE_TTL_LOADER
 #ifdef HAVE_HAL
 	if (tracker_hal_path_is_on_removable_device (indexer->private->hal,
 						     path, 
 						     &mount_point,
 						     NULL)) {
-
 		tracker_removable_device_add_removal (indexer, mount_point, 
 						      path,
 						      tracker_service_get_name (service));
 	}
-#endif
+#endif /* HAVE_HAL */
+#endif /* ENABLE_TTL_LOADER */
+
 	g_free (mount_point);
 	g_free (path);
 }
@@ -3426,9 +3433,11 @@ tracker_indexer_volume_update_state (TrackerIndexer         *indexer,
 	/* tracker_turtle_process_ttl will be spinning the mainloop, therefore
 	   we can already return the DBus method */
 
+#ifdef ENABLE_TTL_LOADER
 	if (enabled) {
 		tracker_removable_device_load (indexer, path);
 	}
+#endif /* ENABLE_TTL_LOADER */
 }
 
 void
diff --git a/src/trackerd/tracker-main.c b/src/trackerd/tracker-main.c
index a315b29..f748b6d 100644
--- a/src/trackerd/tracker-main.c
+++ b/src/trackerd/tracker-main.c
@@ -666,14 +666,14 @@ mount_point_set_cb (DBusGProxy *proxy,
 	TrackerMainPrivate *private;
 
 	if (error) {
-		g_critical ("Indexer couldn't set removable media state for:'%s' in database, %s", 
+		g_critical ("Indexer couldn't set volume state for:'%s' in database, %s", 
 			    (gchar*) user_data,
 			    error ? error->message : "no error given");
 		g_error_free (error);
 
 		tracker_shutdown ();
 	} else {
-		g_message ("Indexer now knows about UDI state:");
+		g_message ("Indexer has now set the state for the volume with UDI:");
 		g_message ("  %s", (gchar*) user_data);
 	}
 		
@@ -696,6 +696,9 @@ mount_point_set_cb (DBusGProxy *proxy,
 			tracker_daemon_signal_statistics ();
 		}
 
+		/* Unpause the indexer */
+		tracker_status_set_is_paused_for_dbus (FALSE);
+			
 		if (!private->mount_points_up) {
 			private->mount_points_up = TRUE;
 
@@ -705,9 +708,10 @@ mount_point_set_cb (DBusGProxy *proxy,
 			 */
 			g_main_loop_quit (private->main_loop);
 		}
-	} else {
-		g_message ("Statistics not being signalled, %d mountable media states left to set still", 
-			   private->mount_points_to_set);
+	} else if (private->mount_points_up) {
+		g_message ("Statistics not being signalled, %d %s remaining", 
+			   private->mount_points_to_set,
+			   private->mount_points_to_set == 1 ? "volume" : "volumes");
 	}
 }
 
@@ -723,7 +727,9 @@ mount_point_added_cb (TrackerHal  *hal,
 
 	private->mount_points_to_set++;
 
-	g_message ("Indexer is being notified about added UDI:");
+	tracker_status_set_is_paused_for_dbus (TRUE);
+
+	g_message ("Indexer is being notified about added volume with UDI:");
 	g_message ("  %s", udi);
 
 	org_freedesktop_Tracker_Indexer_volume_update_state_async (tracker_dbus_indexer_get_proxy (), 
@@ -746,7 +752,9 @@ mount_point_removed_cb (TrackerHal  *hal,
 
 	private->mount_points_to_set++;
 
-	g_message ("Indexer is being notified about removed UDI:");
+	tracker_status_set_is_paused_for_dbus (TRUE);
+
+	g_message ("Indexer is being notified about removed volume with UDI:");
 	g_message ("  %s", udi);
 
 	org_freedesktop_Tracker_Indexer_volume_update_state_async (tracker_dbus_indexer_get_proxy (), 
@@ -767,42 +775,62 @@ set_up_mount_points_cb (DBusGProxy *proxy,
 	GList *roots, *l;
 
 	if (error) {
-		g_critical ("Indexer couldn't disable all removable devices, %s", 
+		g_critical ("Indexer couldn't disable all volumes, %s", 
 			    error ? error->message : "no error given");
 		g_error_free (error);
 		tracker_shutdown ();
 		return;
 	}
 
-	g_message ("Indexer is being notified about ALL UDIs");
+	g_message ("  Done");
+
+	private = g_static_private_get (&private_key);
 
 	hal = user_data;
 	roots = tracker_hal_get_removable_device_udis (hal);
 
-	private = g_static_private_get (&private_key);
-	
-	for (l = roots; l; l = l->next) {
-		gchar       *udi;
-		const gchar *mount_point;
-		gboolean     is_mounted;
+	if (roots) {
+		g_message ("Indexer is being notified about volume states with UDIs:");
+
+		for (l = roots; l; l = l->next) {
+			gchar       *udi;
+			const gchar *mount_point;
+			gboolean     is_mounted;
+			
+			udi = l->data;
+			mount_point = tracker_hal_udi_get_mount_point (hal, udi);
+			is_mounted = tracker_hal_udi_get_is_mounted (hal, udi);
+			
+			g_message ("  %s", udi);
+			
+			private->mount_points_to_set++;
+			
+			org_freedesktop_Tracker_Indexer_volume_update_state_async (tracker_dbus_indexer_get_proxy (), 
+										   udi,
+										   mount_point,
+										   is_mounted,
+										   mount_point_set_cb,
+										   g_strdup (udi));
+		}
 
-		udi = l->data;
-		mount_point = tracker_hal_udi_get_mount_point (hal, udi);
-		is_mounted = tracker_hal_udi_get_is_mounted (hal, udi);
+		g_list_free (roots);
+	} else {
+		g_message ("Indexer does not need to be notified of volume states, none to set");
 
-		g_message ("  %s", udi);
+		tracker_status_set_is_paused_for_dbus (FALSE);
 
-		private->mount_points_to_set++;
+		/* Make sure we stop the main loop used to set up
+		 * mount points on start up if we have no removable
+		 * devices to update in the indexer.
+		 */
+		private->mount_points_up = TRUE;
 
-		org_freedesktop_Tracker_Indexer_volume_update_state_async (tracker_dbus_indexer_get_proxy (), 
-									   udi,
-									   mount_point,
-									   is_mounted,
-									   mount_point_set_cb,
-									   g_strdup (udi));
+		/* We need to stop the main loop, we started
+		 * it so we could wait for mount points to be
+		 * set up successfully in main().
+		 */
+		g_main_loop_quit (private->main_loop);
 	}
-
-	g_list_free (roots);
 }
 
 static void
@@ -812,6 +840,8 @@ set_up_mount_points (TrackerHal *hal)
 
 	private = g_static_private_get (&private_key);
 
+	tracker_status_set_is_paused_for_dbus (TRUE);
+
 	private->mount_points_up = FALSE;
 
 	g_message ("Indexer is being notified to disable all volumes");



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