[tracker/tracker-0.6] Shut trackerd down cleanly, even during initialization. Fixes NB#107962.



commit a9f84232ab41a61d5d1f1fff0425e91a77d850f5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Apr 27 17:16:31 2009 +0200

    Shut trackerd down cleanly, even during initialization. Fixes NB#107962.
    
    * src/trackerd/tracker-status.[ch] (tracker_status_is_initialized): New
      function.
    * src/trackerd/tracker-main.c (tracker_shutdown): Check whether resources
      are available before trying to shut them down.
      (main): Do not enter the main loop if we are already shutting down.
---
 src/trackerd/tracker-main.c   |   19 +++++++++++++++----
 src/trackerd/tracker-status.c |   10 ++++++++++
 src/trackerd/tracker-status.h |    2 ++
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/trackerd/tracker-main.c b/src/trackerd/tracker-main.c
index 2a2fbc7..f181549 100644
--- a/src/trackerd/tracker-main.c
+++ b/src/trackerd/tracker-main.c
@@ -110,6 +110,7 @@ typedef struct {
 	gchar            *ttl_backup_file;
 	
 	gboolean	  reindex_on_shutdown;
+	gboolean          shutdown;
 
 	TrackerProcessor *processor;
 } TrackerMainPrivate;
@@ -1090,7 +1091,7 @@ main (gint argc, gchar *argv[])
 		backup_restore_on_crawling_finished (private->processor);
 	}
 
-	if (tracker_status_get_is_ready ()) {
+	if (!private->shutdown && tracker_status_get_is_ready ()) {
 		private->main_loop = g_main_loop_new (NULL, FALSE);
 		g_main_loop_run (private->main_loop);
 	}
@@ -1161,11 +1162,21 @@ tracker_shutdown (void)
 
 	private = g_static_private_get (&private_key);
 
-	tracker_status_set_is_ready (FALSE);
+	if (private) {
+		if (tracker_status_is_initialized ()) {
+			tracker_status_set_is_ready (FALSE);
+		}
 
-	tracker_processor_stop (private->processor);
+		if (private->processor) {
+			tracker_processor_stop (private->processor);
+		}
 
-	g_main_loop_quit (private->main_loop);
+		if (private->main_loop) {
+			g_main_loop_quit (private->main_loop);
+		}
+
+		private->shutdown = TRUE;
+	}
 }
 
 const gchar *
diff --git a/src/trackerd/tracker-status.c b/src/trackerd/tracker-status.c
index af3f4a0..984653b 100644
--- a/src/trackerd/tracker-status.c
+++ b/src/trackerd/tracker-status.c
@@ -574,6 +574,16 @@ tracker_status_shutdown (void)
 	g_static_private_free (&private_key);
 }
 
+gboolean
+tracker_status_is_initialized (void)
+{
+	TrackerStatusPrivate *private;
+
+	private = g_static_private_get (&private_key);
+
+	return (private != NULL);
+}
+
 GType
 tracker_status_get_type (void)
 {
diff --git a/src/trackerd/tracker-status.h b/src/trackerd/tracker-status.h
index 2191d52..cd05634 100644
--- a/src/trackerd/tracker-status.h
+++ b/src/trackerd/tracker-status.h
@@ -47,6 +47,8 @@ gboolean      tracker_status_init		     (TrackerConfig *config,
 						      TrackerHal    *hal);
 void	      tracker_status_shutdown		     (void);
 
+gboolean      tracker_status_is_initialized          (void);
+
 GType	      tracker_status_get_type		     (void) G_GNUC_CONST;
 const gchar * tracker_status_to_string		     (TrackerStatus  status);
 TrackerStatus tracker_status_get		     (void);



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