tracker r3120 - in trunk: . data/dbus src/tracker-extract src/tracker-indexer
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r3120 - in trunk: . data/dbus src/tracker-extract src/tracker-indexer
- Date: Mon, 23 Mar 2009 15:31:17 +0000 (UTC)
Author: mr
Date: Mon Mar 23 15:31:17 2009
New Revision: 3120
URL: http://svn.gnome.org/viewvc/tracker?rev=3120&view=rev
Log:
* data/dbus/tracker-extract.xml:
* src/tracker-extract/tracker-extract.[ch]:
* src/tracker-indexer/tracker-indexer.c:
* src/tracker-indexer/tracker-module-metadata-utils.c: Added
GetPid API call to extractor. We now call this furst so we know
what process to kill when the extractor misbehaves. The old
solution would kill EVERY tracker-extract process on the system
which (if the user has permissions) is potentially quite bad for
multiple users using Tracker. This should be quicker than the old
solution too.
Modified:
trunk/ChangeLog
trunk/data/dbus/tracker-extract.xml
trunk/src/tracker-extract/tracker-extract.c
trunk/src/tracker-extract/tracker-extract.h
trunk/src/tracker-indexer/tracker-indexer.c
trunk/src/tracker-indexer/tracker-module-metadata-utils.c
Modified: trunk/data/dbus/tracker-extract.xml
==============================================================================
--- trunk/data/dbus/tracker-extract.xml (original)
+++ trunk/data/dbus/tracker-extract.xml Mon Mar 23 15:31:17 2009
@@ -11,6 +11,10 @@
<node name="/">
<interface name="org.freedesktop.Tracker.Extract">
+ <method name="GetPid">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="i" name="value" direction="out" />
+ </method>
<method name="GetMetadata">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="path" direction="in" />
Modified: trunk/src/tracker-extract/tracker-extract.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.c (original)
+++ trunk/src/tracker-extract/tracker-extract.c Mon Mar 23 15:31:17 2009
@@ -368,6 +368,28 @@
}
void
+tracker_extract_get_pid (TrackerExtract *object,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ guint request_id;
+ pid_t value;
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to get PID");
+
+ value = getpid ();
+ tracker_dbus_request_debug (request_id,
+ "PID is %d", value);
+
+ dbus_g_method_return (context, value);
+
+ tracker_dbus_request_success (request_id);
+}
+
+void
tracker_extract_get_metadata (TrackerExtract *object,
const gchar *path,
const gchar *mime,
Modified: trunk/src/tracker-extract/tracker-extract.h
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.h (original)
+++ trunk/src/tracker-extract/tracker-extract.h Mon Mar 23 15:31:17 2009
@@ -51,6 +51,9 @@
GType tracker_extract_get_type (void);
TrackerExtract *tracker_extract_new (void);
+void tracker_extract_get_pid (TrackerExtract *object,
+ DBusGMethodInvocation *context,
+ GError **error);
void tracker_extract_get_metadata (TrackerExtract *object,
const gchar *path,
const gchar *mime,
Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c (original)
+++ trunk/src/tracker-indexer/tracker-indexer.c Mon Mar 23 15:31:17 2009
@@ -2346,7 +2346,7 @@
}
if (current_mtime == db_mtime) {
- g_debug ("'%s' is already up to date in DB, not (re)indexing", path);
+ g_message ("'%s' is already up to date in DB, not (re)indexing", path);
g_free (path);
return FALSE;
Modified: trunk/src/tracker-indexer/tracker-module-metadata-utils.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-module-metadata-utils.c (original)
+++ trunk/src/tracker-indexer/tracker-module-metadata-utils.c Mon Mar 23 15:31:17 2009
@@ -195,42 +195,6 @@
return context;
}
-static GSList *
-get_pids (void)
-{
- GError *error = NULL;
- GDir *dir;
- GSList *pids = NULL;
- const gchar *name;
-
- dir = g_dir_open ("/proc", 0, &error);
- if (error) {
- g_warning ("Could not open /proc, %s\n",
- error ? error->message : "no error given");
- g_clear_error (&error);
- return NULL;
- }
-
- while ((name = g_dir_read_name (dir)) != NULL) {
- gchar c;
- gboolean is_pid = TRUE;
-
- for (c = *name; c && c != ':' && is_pid; c++) {
- is_pid &= g_ascii_isdigit (c);
- }
-
- if (!is_pid) {
- continue;
- }
-
- pids = g_slist_prepend (pids, g_strdup (name));
- }
-
- g_dir_close (dir);
-
- return g_slist_reverse (pids);
-}
-
static void
metadata_utils_add_embedded_data (TrackerModuleMetadata *metadata,
TrackerField *field,
@@ -312,6 +276,7 @@
GHashTable *values = NULL;
GError *error = NULL;
const gchar *service_type;
+ pid_t pid;
service_type = tracker_ontology_get_service_by_mime (mime_type);
if (!service_type) {
@@ -322,15 +287,23 @@
return;
}
+ /* Call extractor to get PID so we can kill it if anything goes wrong. */
+ if (!org_freedesktop_Tracker_Extract_get_pid (get_dbus_extract_proxy (),
+ &pid,
+ &error)) {
+ g_message ("Couldn't get PID from tracker-extract, %s",
+ error ? error->message : "no error given");
+ g_clear_error (&error);
+ return;
+ }
+
/* Call extractor to get data here */
if (!org_freedesktop_Tracker_Extract_get_metadata (get_dbus_extract_proxy (),
path,
mime_type,
&values,
&error)) {
- GSList *pids, *l;
gboolean should_kill = TRUE;
- gboolean was_killed;
if (G_LIKELY (error)) {
switch (error->code) {
@@ -362,70 +335,19 @@
return;
}
- was_killed = FALSE;
-
/* Kill extractor, most likely it got stuck */
g_message ("Attempting to kill tracker-extract with SIGKILL");
-
- pids = get_pids ();
- g_message (" Found %d pids...", g_slist_length (pids));
-
- for (l = pids; l; l = l->next) {
- gchar *filename;
- gchar *contents = NULL;
- gchar **strv;
- filename = g_build_filename ("/proc", l->data, "cmdline", NULL);
- g_file_get_contents (filename, &contents, NULL, &error);
+ if (kill (pid, SIGKILL) == -1) {
+ const gchar *str = g_strerror (errno);
- if (error) {
- g_warning ("Could not open '%s', %s",
- filename,
- error ? error->message : "no error given");
- g_clear_error (&error);
- g_free (contents);
- g_free (filename);
-
- continue;
- }
-
- strv = g_strsplit (contents, "^@", 2);
- if (strv && strv[0]) {
- gchar *basename;
-
- basename = g_path_get_basename (strv[0]);
- if (g_strcmp0 (basename, "tracker-extract") == 0) {
- pid_t p;
-
- p = atoi (l->data);
- g_message (" Found process ID:%d", p);
-
- if (kill (p, SIGKILL) == -1) {
- const gchar *str = g_strerror (errno);
-
- g_message ("Couldn't kill process %d, %s",
- p,
- str ? str : "no error given");
- } else {
- was_killed = TRUE;
- }
- }
-
- g_free (basename);
- }
-
- g_strfreev (strv);
- g_free (contents);
- g_free (filename);
- }
-
- if (!was_killed) {
- g_message (" No process was found to kill");
+ g_message (" Could not kill process %d, %s",
+ pid,
+ str ? str : "no error given");
+ } else {
+ g_message (" Killed process %d", pid);
}
- g_slist_foreach (pids, (GFunc) g_free, NULL);
- g_slist_free (pids);
-
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]