Commit d9d1881c authored by Carlos Garnacho's avatar Carlos Garnacho Committed by Carlos Garnacho

call alarm() prior to processing a file, so the extractor dies if it gets

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.

svn path=/trunk/; revision=2963
parent d0fd2177
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.
2009-02-24 Carlos Garnacho <carlos@imendio.com>
* src/libtracker-db/tracker-db-index.c (tracker_db_index_add_word): Do
......
......@@ -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 @@ get_file_metadata (TrackerExtract *extract,
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 @@ tracker_extract_get_metadata (TrackerExtract *object,
" 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 @@ tracker_extract_get_metadata (TrackerExtract *object,
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);
}
......@@ -134,11 +134,13 @@ signal_handler (int signo)
}
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 @@ initialize_signal_handler (void)
sigaction (SIGTERM, &act, NULL);
sigaction (SIGINT, &act, NULL);
sigaction (SIGHUP, &act, NULL);
sigaction (SIGALRM, &act, NULL);
#endif /* G_OS_WIN32 */
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment