[tracker] tracker-extract: Fixed Ctrl+C not working with -d



commit 1dfcf674dabe817c52ed6479ed2c03075f4c8e89
Author: Martyn Russell <martyn lanedo com>
Date:   Mon Sep 28 15:29:54 2009 +0100

    tracker-extract: Fixed Ctrl+C not working with -d

 src/tracker-extract/tracker-dbus.c    |    4 ++--
 src/tracker-extract/tracker-dbus.h    |    4 ++--
 src/tracker-extract/tracker-extract.c |   14 ++++++++++----
 src/tracker-extract/tracker-extract.h |    2 +-
 src/tracker-extract/tracker-main.c    |   21 ++++++++++++---------
 5 files changed, 27 insertions(+), 18 deletions(-)
---
diff --git a/src/tracker-extract/tracker-dbus.c b/src/tracker-extract/tracker-dbus.c
index 042f1b6..8bf640b 100644
--- a/src/tracker-extract/tracker-dbus.c
+++ b/src/tracker-extract/tracker-dbus.c
@@ -153,7 +153,7 @@ tracker_dbus_shutdown (void)
 }
 
 gboolean
-tracker_dbus_register_objects (void)
+tracker_dbus_register_objects (gboolean disable_shutdown)
 {
 	gpointer object;
 
@@ -163,7 +163,7 @@ tracker_dbus_register_objects (void)
 	}
 
 	/* Add org.freedesktop.Tracker1.Extract */
-	object = tracker_extract_new ();
+	object = tracker_extract_new (disable_shutdown);
 	if (!object) {
 		g_critical ("Could not create TrackerExtract object to register");
 		return FALSE;
diff --git a/src/tracker-extract/tracker-dbus.h b/src/tracker-extract/tracker-dbus.h
index db0d115..05025ae 100644
--- a/src/tracker-extract/tracker-dbus.h
+++ b/src/tracker-extract/tracker-dbus.h
@@ -30,8 +30,8 @@ G_BEGIN_DECLS
 
 gboolean tracker_dbus_init             (void);
 void     tracker_dbus_shutdown         (void);
-gboolean tracker_dbus_register_objects (void);
-GObject *tracker_dbus_get_object       (GType type);
+gboolean tracker_dbus_register_objects (gboolean disable_shutdown);
+GObject *tracker_dbus_get_object       (GType    type);
 
 G_END_DECLS
 
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 0d9fb17..3b2d64b 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -47,6 +47,7 @@ extern gboolean debug;
 typedef struct {
 	GArray *specific_extractors;
 	GArray *generic_extractors;
+	gboolean disable_shutdown;
 } TrackerExtractPrivate;
 
 typedef struct { 
@@ -115,7 +116,7 @@ tracker_extract_finalize (GObject *object)
 }
 
 TrackerExtract *
-tracker_extract_new (void)
+tracker_extract_new (gboolean disable_shutdown)
 {
 	TrackerExtract *object;
 	TrackerExtractPrivate *priv;
@@ -202,6 +203,8 @@ tracker_extract_new (void)
 
 	priv = TRACKER_EXTRACT_GET_PRIVATE (object);
 
+	priv->disable_shutdown = disable_shutdown;
+
 	priv->specific_extractors = specific_extractors;
 	priv->generic_extractors = generic_extractors;
 
@@ -434,7 +437,8 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 			      DBusGMethodInvocation  *context,
 			      GError		    **error)
 {
-	guint       request_id;
+	guint request_id;
+	TrackerExtractPrivate *priv;
 	TrackerSparqlBuilder *sparql = NULL;
 
 	request_id = tracker_dbus_get_next_request_id ();
@@ -449,9 +453,11 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 
 	tracker_dbus_request_debug (request_id,
 				    "  Resetting shutdown timeout");
+
+	priv = TRACKER_EXTRACT_GET_PRIVATE (object);
 	
 	tracker_main_quit_timeout_reset ();
-	if (!debug) {
+	if (!priv->disable_shutdown) {
 		alarm (MAX_EXTRACT_TIME);
 	}
 
@@ -477,7 +483,7 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 		g_error_free (actual_error);
 	}
 
-	if (!debug) {
+	if (!priv->disable_shutdown) {
 		/* Unset alarm so the extractor doesn't die when it's idle */
 		alarm (0);
 	}
diff --git a/src/tracker-extract/tracker-extract.h b/src/tracker-extract/tracker-extract.h
index a18e07d..ce321fc 100644
--- a/src/tracker-extract/tracker-extract.h
+++ b/src/tracker-extract/tracker-extract.h
@@ -50,7 +50,7 @@ struct TrackerExtractClass {
 };
 
 GType           tracker_extract_get_type                (void);
-TrackerExtract *tracker_extract_new                     (void);
+TrackerExtract *tracker_extract_new                     (gboolean                disable_shutdown);
 void            tracker_extract_get_pid                 (TrackerExtract         *object,
 							 DBusGMethodInvocation  *context,
 							 GError                **error);
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index 301b789..fa9dbda 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -70,7 +70,7 @@ static GMainLoop  *main_loop;
 static guint       quit_timeout_id = 0;
 
 static gboolean    version;
-gboolean           debug = FALSE;
+static gboolean    disable_shutdown;
 static gint        verbosity = -1;
 static gchar      *filename;
 static gchar      *mime_type;
@@ -95,9 +95,9 @@ static GOptionEntry  entries[] = {
 	  N_("MIME") },
 	/* Debug run is used to avoid that the mainloop exits, so that
 	 * as a developer you can be relax when running the tool in gdb */
-	{ "debug", 'd', 0,
-	  G_OPTION_ARG_NONE, &debug,
-	  N_("Debug (default = off)"),
+	{ "disable-shutdown", 'd', 0,
+	  G_OPTION_ARG_NONE, &disable_shutdown,
+	  N_("Disable shutting down after 30 seconds of inactivity"),
 	  NULL },
 
 	{ NULL }
@@ -108,7 +108,7 @@ quit_timeout_cb (gpointer user_data)
 {
 	quit_timeout_id = 0;
 	
-	if (!debug) {
+	if (!disable_shutdown) {
 		g_main_loop_quit (main_loop);
 	} else {
 		g_debug ("Would have quit the mainloop");
@@ -189,11 +189,12 @@ signal_handler (int signo)
 	case SIGTERM:
 	case SIGINT:
 		in_loop = TRUE;
+		disable_shutdown = FALSE;
 		quit_timeout_cb (NULL);
 	default:
 		if (g_strsignal (signo)) {
 			g_print ("\n");
-			g_print ("Received signal:%d->'%s'",
+			g_print ("Received signal:%d->'%s'\n",
 				 signo,
 				 g_strsignal (signo));
 		}
@@ -310,7 +311,9 @@ main (int argc, char *argv[])
 		return EXIT_SUCCESS;
 	}
 
-	g_print ("Initializing tracker-extract...%s\n", debug ? "Running in debug mode" : "");
+	g_print ("Initializing tracker-extract...\n");
+	g_print ("  Shutdown after 30 seconds of inactivitiy is %s\n",
+		 disable_shutdown ? "disabled" : "enabled");
 
 	initialize_signal_handler ();
 
@@ -339,7 +342,7 @@ main (int argc, char *argv[])
 		GFile *file;
 		gchar *uri;
 
-		extract = tracker_extract_new ();
+		extract = tracker_extract_new (disable_shutdown);
 		if (!extract) {
 			return EXIT_FAILURE;
 		}
@@ -376,7 +379,7 @@ main (int argc, char *argv[])
 	g_free (log_filename);
 
 	/* Make Tracker available for introspection */
-	if (!tracker_dbus_register_objects ()) {
+	if (!tracker_dbus_register_objects (disable_shutdown)) {
 		g_object_unref (config);
 
 		return EXIT_FAILURE;



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