tracker r2963 - in trunk: . src/tracker-extract



Author: carlosg
Date: Tue Feb 24 16:52:02 2009
New Revision: 2963
URL: http://svn.gnome.org/viewvc/tracker?rev=2963&view=rev

Log:
2009-02-24  Carlos Garnacho  <carlos imendio com>

        * src/tracker-extract/tracker-extract.c:
        * src/tracker-extract/tracker-main.c: call alarm() prior to processing
        a file, so the extractor dies if it gets stuck.

Modified:
   trunk/ChangeLog
   trunk/src/tracker-extract/tracker-extract.c
   trunk/src/tracker-extract/tracker-main.c

Modified: trunk/src/tracker-extract/tracker-extract.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.c	(original)
+++ trunk/src/tracker-extract/tracker-extract.c	Tue Feb 24 16:52:02 2009
@@ -21,6 +21,7 @@
 #include "config.h"
 
 #include <string.h>
+#include <unistd.h>
 
 #include <gmodule.h>
 #include <gio/gio.h>
@@ -31,6 +32,7 @@
 #include "tracker-dbus.h"
 #include "tracker-extract.h"
 
+#define MAX_EXTRACT_TIME 5
 #define TRACKER_EXTRACT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_EXTRACT, TrackerExtractPrivate))
 
 typedef struct {
@@ -210,6 +212,8 @@
 	path_in_locale = g_filename_from_utf8 (path_used, -1, NULL, NULL, NULL);
 	g_free (path_used);
 
+	while (TRUE);
+
 	if (!path_in_locale) {
 		g_warning ("Could not convert path from UTF-8 to locale");
 		g_free (path_used);
@@ -390,8 +394,10 @@
 				    "  Resetting shutdown timeout");
 	
 	tracker_main_quit_timeout_reset ();
+	alarm (MAX_EXTRACT_TIME);
 
 	values = get_file_metadata (object, request_id, path, mime);
+
 	if (values) {
 		g_hash_table_foreach (values, 
 				      print_file_metadata_item, 
@@ -410,4 +416,7 @@
 		dbus_g_method_return_error (context, actual_error);
 		g_error_free (actual_error);
 	}
+
+	/* Unset alarm so the extractor doesn't die when it's idle */
+	alarm (0);
 }

Modified: trunk/src/tracker-extract/tracker-main.c
==============================================================================
--- trunk/src/tracker-extract/tracker-main.c	(original)
+++ trunk/src/tracker-extract/tracker-main.c	Tue Feb 24 16:52:02 2009
@@ -134,11 +134,13 @@
 	}
 
 	switch (signo) {
+	case SIGALRM:
+		exit (EXIT_FAILURE);
+		break;
 	case SIGTERM:
 	case SIGINT:
 		in_loop = TRUE;
 		quit_timeout_cb (NULL);
-
 	default:
 		if (g_strsignal (signo)) {
 			g_print ("\n");
@@ -165,6 +167,7 @@
 	sigaction (SIGTERM, &act, NULL);
 	sigaction (SIGINT,  &act, NULL);
 	sigaction (SIGHUP,  &act, NULL);
+	sigaction (SIGALRM,  &act, NULL);
 #endif /* G_OS_WIN32 */
 }
 



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