tracker r2186 - in branches/indexer-split: . src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2186 - in branches/indexer-split: . src/tracker-indexer
- Date: Fri, 29 Aug 2008 13:25:20 +0000 (UTC)
Author: carlosg
Date: Fri Aug 29 13:25:20 2008
New Revision: 2186
URL: http://svn.gnome.org/viewvc/tracker?rev=2186&view=rev
Log:
2008-08-29 Carlos Garnacho <carlos imendio com>
* src/tracker-indexer/tracker-main.c (initialize_signal_handler):
Ignore SIGPIPE, so we can handle it ourselves.
* src/tracker-indexer/tracker-metadata-utils.c: It's possible that the
indexer is trying to write to the metadata extractor before it
realizes it has quit/crashed. Handle errors writing to a broken pipe
and respawn the metadata process context in that case.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/tracker-main.c
branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c
Modified: branches/indexer-split/src/tracker-indexer/tracker-main.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-main.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-main.c Fri Aug 29 13:25:20 2008
@@ -146,7 +146,6 @@
case SIGBUS:
case SIGILL:
case SIGFPE:
- case SIGPIPE:
case SIGABRT:
case SIGTERM:
case SIGINT:
@@ -165,14 +164,18 @@
initialize_signal_handler (void)
{
#ifndef OS_WIN32
- struct sigaction act;
- sigset_t empty_mask;
+ struct sigaction act, ign_act;
+ sigset_t empty_mask;
sigemptyset (&empty_mask);
act.sa_handler = signal_handler;
act.sa_mask = empty_mask;
act.sa_flags = 0;
+ ign_act.sa_handler = SIG_IGN;
+ ign_act.sa_mask = empty_mask;
+ ign_act.sa_flags = 0;
+
sigaction (SIGTERM, &act, NULL);
sigaction (SIGILL, &act, NULL);
sigaction (SIGBUS, &act, NULL);
@@ -182,6 +185,7 @@
sigaction (SIGABRT, &act, NULL);
sigaction (SIGUSR1, &act, NULL);
sigaction (SIGINT, &act, NULL);
+ sigaction (SIGPIPE, &ign_act, NULL);
#endif
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c Fri Aug 29 13:25:20 2008
@@ -161,25 +161,45 @@
return TRUE;
}
+static gboolean
+create_metadata_context (void)
+{
+ const gchar *argv[2] = { LIBEXEC_PATH G_DIR_SEPARATOR_S "tracker-extract", NULL };
+
+ if (metadata_context) {
+ destroy_process_context (metadata_context);
+ metadata_context = NULL;
+ }
+
+ metadata_context = create_process_context (argv);
+
+ if (!metadata_context) {
+ return FALSE;
+ }
+
+ g_io_add_watch (metadata_context->stdout_channel,
+ G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
+ tracker_metadata_read,
+ metadata_context);
+
+ return TRUE;
+}
+
static gchar **
tracker_metadata_query_file (const gchar *path,
const gchar *mimetype)
{
- const gchar *argv[2] = { LIBEXEC_PATH G_DIR_SEPARATOR_S "tracker-extract", NULL };
gchar *utf_path, *str;
GPtrArray *array;
GIOStatus status;
+ GError *error = NULL;
if (!path || !mimetype) {
return NULL;
}
- if (!metadata_context) {
- metadata_context = create_process_context (argv);
-
- if (!metadata_context) {
- return NULL;
- }
+ if (!metadata_context && !create_metadata_context ()) {
+ return NULL;
}
utf_path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
@@ -192,15 +212,34 @@
array = g_ptr_array_sized_new (10);
metadata_context->data = array;
- g_io_add_watch (metadata_context->stdout_channel,
- G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
- tracker_metadata_read,
- metadata_context);
+ str = g_strdup_printf ("%s\n%s\n", utf_path, mimetype);
+ g_free (utf_path);
/* write path and mimetype */
- str = g_strdup_printf ("%s\n%s\n", utf_path, mimetype);
- status = g_io_channel_write_chars (metadata_context->stdin_channel, str, -1, NULL, NULL);
- g_io_channel_flush (metadata_context->stdin_channel, NULL);
+ g_io_channel_write_chars (metadata_context->stdin_channel, str, -1, NULL, NULL);
+ status = g_io_channel_flush (metadata_context->stdin_channel, &error);
+
+ if (status == G_IO_STATUS_ERROR &&
+ error &&
+ g_error_matches (error, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_PIPE)) {
+ /* Looks like the external extractor
+ * process has died before the child watch
+ * could handle it, try respawning.
+ */
+ g_error_free (error);
+
+ create_metadata_context ();
+ metadata_context->data = array;
+
+ g_io_channel_write_chars (metadata_context->stdin_channel, str, -1, NULL, NULL);
+ status = g_io_channel_flush (metadata_context->stdin_channel, NULL);
+
+ if (status == G_IO_STATUS_ERROR) {
+ /* No point in trying again */
+ g_free (str);
+ return NULL;
+ }
+ }
/* It will block here until all incoming
* metadata has been processed
@@ -213,7 +252,6 @@
metadata_context->data = NULL;
}
- g_free (utf_path);
g_free (str);
return (gchar **) g_ptr_array_free (array, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]