tracker r1506 - in branches/indexer-split: . src/tracker-indexer src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1506 - in branches/indexer-split: . src/tracker-indexer src/trackerd
- Date: Wed, 28 May 2008 09:24:53 +0000 (UTC)
Author: mr
Date: Wed May 28 09:24:52 2008
New Revision: 1506
URL: http://svn.gnome.org/viewvc/tracker?rev=1506&view=rev
Log:
* configure.ac: Changed the IOPRIO_SUPPORT to HAVE_IOPRIO since
thats more consistent with naming conventions.
* src/tracker-indexer/Makefile.am:
* src/tracker-indexer/tracker-indexer.c:
* src/tracker-indexer/tracker-ioprio.[ch]:
* src/trackerd/Makefile.am: Moved the tracker-ioprio.[ch] to the
indexer directory, they are only needed there. Also, moved the
nice() function call to the indexer, the daemon doesn't need jthat
either.
* src/tracker-indexer/main.c: Removed all command line options
except verbosity and reindex, these will not be needed except for
debugging generally. Also use the same jargon about copyright, etc
when starting up as the daemon. Added log support, we write to the
same place as the daemon does, except it is called
tracker-indexer.log.
* src/trackerd/tracker-main.c: Changed the log to trackerd.log
from tracker.log.
Added:
branches/indexer-split/src/tracker-indexer/tracker-ioprio.c
- copied, changed from r1500, /branches/indexer-split/src/trackerd/tracker-ioprio.c
branches/indexer-split/src/tracker-indexer/tracker-ioprio.h
- copied, changed from r1500, /branches/indexer-split/src/trackerd/tracker-ioprio.h
Removed:
branches/indexer-split/src/trackerd/tracker-ioprio.c
branches/indexer-split/src/trackerd/tracker-ioprio.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/configure.ac
branches/indexer-split/src/tracker-indexer/Makefile.am
branches/indexer-split/src/tracker-indexer/main.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/trackerd/Makefile.am
branches/indexer-split/src/trackerd/tracker-main.c
Modified: branches/indexer-split/configure.ac
==============================================================================
--- branches/indexer-split/configure.ac (original)
+++ branches/indexer-split/configure.ac Wed May 28 09:24:52 2008
@@ -756,7 +756,7 @@
####################################################################
AC_MSG_CHECKING([[checking ioprio support]])
-ioprio_support=no
+have_ioprio=no
AC_RUN_IFELSE([ AC_LANG_PROGRAM([[
#include <stdlib.h>
#include <errno.h>
@@ -769,8 +769,8 @@
]], [[
exit(ioprio_get(1,0));
]]) ],
- [ AC_DEFINE(IOPRIO_SUPPORT,[],[Define ioprio support]) ioprio_support=yes ])
-AC_MSG_RESULT([$ioprio_support])
+ [ AC_DEFINE(HAVE_IOPRIO,[],[Define ioprio support]) have_ioprio=yes ])
+AC_MSG_RESULT([$have_ioprio])
#####################################################
@@ -855,7 +855,7 @@
build with debug symbols: $enable_debug_code
file monitor backend to be used: $primary_backend
inotify header location: $inotify_header
- ioprio support: $ioprio_support
+ ioprio support: $have_ioprio
Win32: $native_win32
HAL support: $have_hal
unac accent stripper support: $enable_unac
Modified: branches/indexer-split/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-indexer/Makefile.am (original)
+++ branches/indexer-split/src/tracker-indexer/Makefile.am Wed May 28 09:24:52 2008
@@ -5,6 +5,7 @@
-DLIBDIR=\""$(libdir)"\" \
-DLOCALEDIR=\""$(localedir)"\" \
-DINDEXER_MODULES_DIR=\""$(libdir)"/tracker/indexer-modules\" \
+ -DG_LOG_DOMAIN=\"Tracker-Indexer\" \
$(GLIB2_CFLAGS) \
$(GMODULE_CFLAGS) \
-I$(top_srcdir)/src
@@ -13,6 +14,8 @@
tracker_indexer_SOURCES = \
main.c \
+ tracker-ioprio.c \
+ tracker-ioprio.h \
tracker-indexer.c \
tracker-indexer.h \
tracker-indexer-module.c \
Modified: branches/indexer-split/src/tracker-indexer/main.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/main.c (original)
+++ branches/indexer-split/src/tracker-indexer/main.c Wed May 28 09:24:52 2008
@@ -23,52 +23,40 @@
#include <stdlib.h>
#include <locale.h>
#include <signal.h>
+#include <errno.h>
+#include <unistd.h>
#include <glib/gi18n.h>
#include <glib-object.h>
+#include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-log.h>
+
#include "tracker-indexer.h"
-#define COPYRIGHT \
- "Tracker version " PACKAGE_VERSION "\n" \
- "Copyright (c) 2005-2008 by Jamie McCracken (jamiemcc gnome org)"
+#ifdef HAVE_IOPRIO
+#include "tracker-ioprio.h"
+#endif
+
+#define ABOUT \
+ "Tracker " VERSION "\n" \
+ "Copyright (c) 2005-2008 Jamie McCracken (jamiemcc gnome org)\n"
-#define WARRANTY \
+#define LICENSE \
"This program is free software and comes without any warranty.\n" \
- "It is licensed under version 2 or later of the General Public\n" \
- "License which can be viewed at:\n" \
- "\n" \
- "\thttp://www.gnu.org/licenses/gpl.txt"
+ "It is licensed under version 2 or later of the General Public " \
+ "License which can be viewed at:\n" \
+ "\n" \
+ " http://www.gnu.org/licenses/gpl.txt\n"
static GMainLoop *main_loop;
-static gchar **no_watch_dirs;
-static gchar **watch_dirs;
-static gchar **crawl_dirs;
-static gchar *language;
-static gboolean disable_indexing;
static gboolean reindex;
-static gboolean fatal_errors;
-static gboolean low_memory;
-static gint throttle = -1;
-static gint verbosity;
-static gint initial_sleep = -1;
+static gint verbosity = -1;
static GOptionEntry entries[] = {
- { "exclude-dir", 'e', 0, G_OPTION_ARG_STRING_ARRAY, &no_watch_dirs,
- N_("Directory to exclude from indexing"),
- N_("/PATH/DIR")
- },
- { "include-dir", 'i', 0, G_OPTION_ARG_STRING_ARRAY, &watch_dirs,
- N_("Directory to include in indexing"),
- N_("/PATH/DIR")
- },
- { "crawl-dir", 'c', 0, G_OPTION_ARG_STRING_ARRAY, &crawl_dirs,
- N_("Directory to crawl for indexing at start up only"),
- N_("/PATH/DIR")
- },
- { "no-indexing", 'n', 0, G_OPTION_ARG_NONE, &disable_indexing,
- N_("Disable any indexing or watching taking place"),
+ { "reindex", 'R', 0, G_OPTION_ARG_NONE, &reindex,
+ N_("Force a re-index of all content"),
NULL
},
{ "verbosity", 'v', 0, G_OPTION_ARG_INT, &verbosity,
@@ -76,33 +64,6 @@
"are 0=errors, 1=minimal, 2=detailed, 3=debug"),
N_("VALUE")
},
- { "throttle", 't', 0, G_OPTION_ARG_INT, &throttle,
- N_("Value to use for throttling indexing. Value must be in "
- "range 0-99 (default=0) with lower values increasing "
- "indexing speed"),
- N_("VALUE")
- },
- { "low-memory", 'm', 0, G_OPTION_ARG_NONE, &low_memory,
- N_("Minimizes the use of memory but may slow indexing down"),
- NULL
- },
- { "initial-sleep", 's', 0, G_OPTION_ARG_INT, &initial_sleep,
- N_("Initial sleep time, just before indexing, in seconds"),
- NULL
- },
- { "language", 'l', 0, G_OPTION_ARG_STRING, &language,
- N_("Language to use for stemmer and stop words list "
- "(ISO 639-1 2 characters code)"),
- N_("LANG")
- },
- { "reindex", 'R', 0, G_OPTION_ARG_NONE, &reindex,
- N_("Force a re-index of all content"),
- NULL
- },
- { "fatal-errors", 'f', 0, G_OPTION_ARG_NONE, &fatal_errors,
- N_("Make tracker errors fatal"),
- NULL
- },
{ NULL }
};
@@ -148,6 +109,30 @@
}
static void
+initialise_signal_handler (void)
+{
+#ifndef OS_WIN32
+ struct sigaction act;
+ sigset_t empty_mask;
+
+ sigemptyset (&empty_mask);
+ act.sa_handler = signal_handler;
+ act.sa_mask = empty_mask;
+ act.sa_flags = 0;
+
+ sigaction (SIGTERM, &act, NULL);
+ sigaction (SIGILL, &act, NULL);
+ sigaction (SIGBUS, &act, NULL);
+ sigaction (SIGFPE, &act, NULL);
+ sigaction (SIGHUP, &act, NULL);
+ sigaction (SIGSEGV, &act, NULL);
+ sigaction (SIGABRT, &act, NULL);
+ sigaction (SIGUSR1, &act, NULL);
+ sigaction (SIGINT, &act, NULL);
+#endif
+}
+
+static void
indexer_finished_cb (TrackerIndexer *indexer,
gpointer user_data)
{
@@ -158,14 +143,12 @@
main (gint argc, gchar *argv[])
{
TrackerIndexer *indexer;
+ TrackerConfig *config;
GOptionContext *context;
GError *error = NULL;
gchar *summary = NULL;
gchar *example;
-#ifndef OS_WIN32
- struct sigaction act;
- sigset_t empty_mask;
-#endif
+ gchar *log_filename;
g_type_init ();
@@ -210,31 +193,49 @@
g_free (summary);
g_free (example);
- g_print ("\n"
- COPYRIGHT "\n"
- "\n"
- WARRANTY "\n"
- "\n");
+ g_print ("\n" ABOUT "\n" LICENSE "\n");
+ g_print ("Initializing tracker-indexer...\n");
-#ifndef OS_WIN32
- /* trap signals */
- sigemptyset (&empty_mask);
- act.sa_handler = signal_handler;
- act.sa_mask = empty_mask;
- act.sa_flags = 0;
- sigaction (SIGTERM, &act, NULL);
- sigaction (SIGILL, &act, NULL);
- sigaction (SIGBUS, &act, NULL);
- sigaction (SIGFPE, &act, NULL);
- sigaction (SIGHUP, &act, NULL);
- sigaction (SIGSEGV, &act, NULL);
- sigaction (SIGABRT, &act, NULL);
- sigaction (SIGUSR1, &act, NULL);
- sigaction (SIGINT, &act, NULL);
+ initialise_signal_handler ();
+
+ /* Initialise logging */
+ config = tracker_config_new ();
+
+ if (verbosity > -1) {
+ tracker_config_set_verbosity (config, verbosity);
+ }
+
+ log_filename = g_build_filename (g_get_user_data_dir (),
+ "tracker",
+ "tracker-indexer.log",
+ NULL);
+
+ tracker_log_init (log_filename, tracker_config_get_verbosity (config));
+ g_message ("Starting log");
+ g_free (log_filename);
+
+#ifdef HAVE_IOPRIO
+ /* Set IO priority */
+ tracker_ioprio_init ();
#endif
- g_print ("Initializing...\n");
+ /* Set child's niceness to 19 */
+ errno = 0;
+
+ /* nice() uses attribute "warn_unused_result" and so complains
+ * if we do not check its returned value. But it seems that
+ * since glibc 2.2.4, nice() can return -1 on a successful
+ * call so we have to check value of errno too. Stupid...
+ */
+ if (nice (19) == -1 && errno) {
+ const gchar *str;
+
+ str = g_strerror (errno);
+ g_message ("Couldn't set nice value to 19, %s",
+ str ? str : "no error given");
+ }
+ /* Create the indexer and run the main loop */
indexer = tracker_indexer_new (reindex);
main_loop = g_main_loop_new (NULL, FALSE);
@@ -243,9 +244,10 @@
g_main_loop_run (main_loop);
- g_object_unref (indexer);
+ g_message ("Shutting down...\n");
- g_print ("Shutting down...\n");
+ g_object_unref (indexer);
+ g_object_unref (config);
return EXIT_SUCCESS;
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Wed May 28 09:24:52 2008
@@ -337,7 +337,7 @@
if (!ignore) {
g_queue_push_tail (priv->dir_queue, info);
} else {
- g_message ("Ignoring directory: %s\n", info->path);
+ g_message ("Ignoring directory:'%s'", info->path);
path_info_free (info);
}
@@ -350,7 +350,7 @@
{
GHashTable *metadata;
- g_message ("Processing file: %s\n", info->path);
+ g_message ("Processing file:'%s'", info->path);
metadata = tracker_indexer_module_get_file_metadata (info->module, info->path);
@@ -361,9 +361,9 @@
keys = g_hash_table_get_keys (metadata);
for (k = keys; k; k = k->next) {
- g_print (" %s = %s\n",
- (gchar *) k->data,
- (gchar *) g_hash_table_lookup (metadata, k->data));
+ g_message (" %s = %s",
+ (gchar*) k->data,
+ (gchar*) g_hash_table_lookup (metadata, k->data));
}
g_hash_table_destroy (metadata);
@@ -379,7 +379,7 @@
const gchar *name;
GDir *dir;
- g_message ("Processing directory: %s\n", info->path);
+ g_message ("Processing directory:'%s'", info->path);
dir = g_dir_open (info->path, 0, NULL);
@@ -416,7 +416,7 @@
gchar **dirs;
gint i;
- g_message ("Starting module: %s\n", module_name);
+ g_message ("Starting module:'%s'", module_name);
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
module = g_hash_table_lookup (priv->indexer_modules, module_name);
@@ -448,15 +448,15 @@
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
if ((path = g_queue_pop_head (priv->file_process_queue)) != NULL) {
- /* process file */
+ /* Process file */
process_file (indexer, path);
path_info_free (path);
} else if ((path = g_queue_pop_head (priv->dir_queue)) != NULL) {
- /* process directory contents */
+ /* Process directory contents */
process_directory (indexer, path, TRUE);
path_info_free (path);
} else {
- /* dirs/files queues are empty, process the next module */
+ /* Dirs/files queues are empty, process the next module */
if (!priv->current_module) {
priv->current_module = priv->module_names;
} else {
@@ -464,7 +464,7 @@
}
if (!priv->current_module) {
- /* no more modules to query, we're done */
+ /* No more modules to query, we're done */
g_signal_emit (indexer, signals[FINISHED], 0);
return FALSE;
}
Copied: branches/indexer-split/src/tracker-indexer/tracker-ioprio.c (from r1500, /branches/indexer-split/src/trackerd/tracker-ioprio.c)
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-ioprio.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-ioprio.c Wed May 28 09:24:52 2008
@@ -1,10 +1,10 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2005, Novell, Inc.
* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2006, Anders Aagaard
*
- * Based mostly on code by
- * Robert Love <rml novell com>
- *
- * Copyright (C) 2005 Novell, Inc.
+ * Based mostly on code by Robert Love <rml novell com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,13 +27,15 @@
#include "config.h"
-#ifdef IOPRIO_SUPPORT
+#ifdef HAVE_IOPRIO
#include <stdio.h>
#include <errno.h>
+
#ifdef HAVE_LINUX_UNISTD_H
#include <linux/unistd.h>
#endif
+
#include <sys/syscall.h>
#include <unistd.h>
@@ -41,8 +43,6 @@
#include <libtracker-common/tracker-log.h>
-#include <tracker-utils.h>
-
#include "tracker-ioprio.h"
#ifndef __NR_ioprio_set
@@ -90,16 +90,13 @@
IOPRIO_CLASS_IDLE,
};
-
enum {
IOPRIO_WHO_PROCESS = 1,
IOPRIO_WHO_PGRP,
IOPRIO_WHO_USER,
};
-
-#define IOPRIO_CLASS_SHIFT 13
-
+#define IOPRIO_CLASS_SHIFT 13
static inline int
ioprio_set (int which, int who, int ioprio_val)
@@ -107,8 +104,8 @@
return syscall (__NR_ioprio_set, which, who, ioprio_val);
}
-
-int set_io_priority_idle (void)
+static int
+set_io_priority_idle (void)
{
int ioprio, ioclass;
@@ -118,7 +115,8 @@
return ioprio_set (IOPRIO_WHO_PROCESS, 0, ioprio | ioclass);
}
-int set_io_priority_best_effort (int ioprio_val)
+static int
+set_io_priority_best_effort (int ioprio_val)
{
int ioclass;
@@ -127,20 +125,18 @@
return ioprio_set (IOPRIO_WHO_PROCESS, 0, ioprio_val | ioclass);
}
-
-
void
-ioprio (void)
+tracker_ioprio_init (void)
{
- g_message ("Setting ioprio...");
+ g_message ("Setting IO priority...");
if (set_io_priority_idle () == -1) {
- g_print ("Could not set idle IO priority...attempting best effort 7 priority\n");
+ g_message ("Could not set idle IO priority, attempting best effort of 7");
+
if (set_io_priority_best_effort (7) == -1) {
- g_warning ("Could not set IO priority");
+ g_message ("Could not set best effort IO priority either, giving up");
}
}
-
}
-#endif
+#endif /* HAVE_IOPRIO */
Copied: branches/indexer-split/src/tracker-indexer/tracker-ioprio.h (from r1500, /branches/indexer-split/src/trackerd/tracker-ioprio.h)
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-ioprio.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-ioprio.h Wed May 28 09:24:52 2008
@@ -18,15 +18,17 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TRACKERD_IOPRIO_H__
-#define __TRACKERD_IOPRIO_H__
+#ifndef __TRACKER_IOPRIO_H__
+#define __TRACKER_IOPRIO_H__
G_BEGIN_DECLS
-#ifdef IOPRIO_SUPPORT
-void ioprio (void);
-#endif /* IOPRIO_SUPPORT */
+#ifdef HAVE_IOPRIO
+
+void tracker_ioprio_init (void);
+
+#endif /* HAVE_IOPRIO */
G_END_DECLS
-#endif /* __TRACKERD_IOPRIO_H__ */
+#endif /* __TRACKER_IOPRIO_H__ */
Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/indexer-split/src/trackerd/Makefile.am Wed May 28 09:24:52 2008
@@ -109,8 +109,6 @@
tracker-rdf-query.h \
tracker-utils.c \
tracker-utils.h \
- tracker-ioprio.c \
- tracker-ioprio.h \
tracker-watch.h \
tracker-status.c \
tracker-status.h \
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Wed May 28 09:24:52 2008
@@ -26,20 +26,15 @@
#include "config.h"
#include <signal.h>
-#include <errno.h>
#include <locale.h>
#include <string.h>
-#include <unistd.h>
+#include <unistd.h>
#include <fcntl.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include <glib/gpattern.h>
-#ifdef IOPRIO_SUPPORT
-#include "tracker-ioprio.h"
-#endif
-
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-language.h>
#include <libtracker-common/tracker-log.h>
@@ -495,7 +490,7 @@
/* Private locations */
log_filename = g_build_filename (g_get_user_data_dir (),
"tracker",
- "tracker.log",
+ "trackerd.log",
NULL);
}
@@ -871,7 +866,7 @@
/* Print information */
g_print ("\n" ABOUT "\n" LICENSE "\n");
- g_print ("Initialising tracker...\n");
+ g_print ("Initializing trackerd...\n");
initialise_signal_handler ();
@@ -936,8 +931,7 @@
}
/* Initialise other subsystems */
- tracker_log_init (log_filename,
- tracker_config_get_verbosity (tracker->config));
+ tracker_log_init (log_filename, tracker_config_get_verbosity (tracker->config));
g_message ("Starting log");
if (!tracker_dbus_preinit (tracker, &connection, &proxy, &xesam))
@@ -964,22 +958,6 @@
tracker->readonly = check_multiple_instances ();
- /* Set child's niceness to 19 */
- errno = 0;
-
- /* nice() uses attribute "warn_unused_result" and so complains
- * if we do not check its returned value. But it seems that
- * since glibc 2.2.4, nice() can return -1 on a successful
- * call so we have to check value of errno too. Stupid...
- */
- if (nice (19) == -1 && errno) {
- g_message ("Couldn't set nice() value");
- }
-
-#ifdef IOPRIO_SUPPORT
- ioprio ();
-#endif
-
if (!tracker_db_load_prepared_queries ()) {
g_critical ("Could not initialize database engine!");
return EXIT_FAILURE;
@@ -1022,6 +1000,8 @@
g_main_loop_run (main_loop);
}
+ g_message ("Shutting down...\n");
+
/*
* Shutdown the daemon
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]