[tracker/writeback-refactor-rebase: 15/65] tracker-writeback: Add shutdown timeout to Writeback service



commit 52113efbcd129ac1a8081e98d0452bf7fe3d741b
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Jul 15 12:07:41 2011 +0200

    tracker-writeback: Add shutdown timeout to Writeback service

 src/tracker-writeback/tracker-main.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-main.c b/src/tracker-writeback/tracker-main.c
index f42fa69..14c70f2 100644
--- a/src/tracker-writeback/tracker-main.c
+++ b/src/tracker-writeback/tracker-main.c
@@ -41,8 +41,11 @@
 	"\n" \
 	"  http://www.gnu.org/licenses/gpl.txt\n";
 
+#define QUIT_TIMEOUT 30 /* 1/2 minutes worth of seconds */
+
 static gboolean      version;
 static gint          verbosity = -1;
+static gboolean      disable_shutdown;
 
 static GOptionEntry  entries[] = {
 	{ "version", 'V', 0,
@@ -54,6 +57,12 @@ static GOptionEntry  entries[] = {
 	  N_("Logging, 0 = errors only, "
 	     "1 = minimal, 2 = detailed and 3 = debug (default=0)"),
 	  NULL },
+	/* 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 */
+	{ "disable-shutdown", 'd', 0,
+	  G_OPTION_ARG_NONE, &disable_shutdown,
+	  N_("Disable shutting down after 30 seconds of inactivity"),
+	  NULL },
 	{ NULL }
 };
 
@@ -76,6 +85,7 @@ main (int   argc,
 	GMainLoop *loop;
 	GError *error = NULL;
 	gchar *log_filename;
+	guint shutdown_timeout;
 
 	g_thread_init (NULL);
 
@@ -116,10 +126,13 @@ main (int   argc,
 
 	sanity_check_option_values (config);
 
-#warning todo here
+	if (disable_shutdown) {
+		shutdown_timeout = 0;
+	} else {
+		shutdown_timeout = QUIT_TIMEOUT;
+	}
 
-	// get correct value from config here
-	controller = tracker_controller_new (9999, &error);
+	controller = tracker_controller_new (shutdown_timeout, &error);
 
 	if (error) {
 		g_critical ("Error creating controller: %s", error->message);



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