tracker r3085 - in trunk: . src/tracker-extract src/tracker-indexer src/trackerd



Author: pvanhoof
Date: Fri Mar 13 16:23:49 2009
New Revision: 3085
URL: http://svn.gnome.org/viewvc/tracker?rev=3085&view=rev

Log:
2009-03-13  Philip Van Hoof  <philip codeminded be>

        * src/tracker-indexer/tracker-main.c:
        * src/trackerd/tracker-main.c:
        * src/tracker-extract/tracker-main.c: Reverting SCHED_IDLE and setting
        the extractor to nice(). We don't want to go into SCHED_IDLE else will
        any app with a bug like "while(1);" make us strave. This is really a
        bad idea.

        Apps that want to have a prio over tracker's processes should simply
        use SCHED_FIFO themselves. Don't require apps to run at a lower prio,
        run at a higher prio yourself if you are indeed realtime.

        Keeping the nice() value so that for a normal desktop we run at a
        level that is lower-than-everybody-else.




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

Modified: trunk/src/tracker-extract/tracker-main.c
==============================================================================
--- trunk/src/tracker-extract/tracker-main.c	(original)
+++ trunk/src/tracker-extract/tracker-main.c	Fri Mar 13 16:23:49 2009
@@ -26,6 +26,11 @@
 #include <stdlib.h>
 #include <locale.h>
 #include <signal.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/sched.h>
+#include <sched.h>
 
 #include <glib.h>
 #include <glib-object.h>
@@ -40,18 +45,12 @@
 #include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-os-dependant.h>
 #include <libtracker-common/tracker-thumbnailer.h>
+#include <libtracker-common/tracker-ioprio.h>
 
 #include "tracker-main.h"
 #include "tracker-dbus.h"
 #include "tracker-extract.h"
 
-/* Temporary hack for out of date kernels, also, this value may not be
- * the same on all architectures, but it is for x86.
- */
-#ifndef SCHED_IDLE
-#define SCHED_IDLE 5
-#endif
-
 #define ABOUT								  \
 	"Tracker " PACKAGE_VERSION "\n"
 
@@ -115,6 +114,30 @@
 						 NULL);
 }
 
+
+static void
+initialize_priority (void)
+{
+	/* Set disk IO priority and scheduling */
+	tracker_ioprio_init ();
+
+	/* Set process priority:
+	 * The nice() function 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... 
+	 */
+	g_message ("Setting process priority");
+
+	if (nice (19) == -1) {
+		const gchar *str = g_strerror (errno);
+
+		g_message ("Couldn't set nice value to 19, %s",
+			   str ? str : "no error given");
+	}
+}
+
 static void
 initialize_directories (void)
 {
@@ -201,6 +224,9 @@
 	g_option_context_add_main_entries (context, entries, NULL);
 	g_option_context_parse (context, &argc, &argv, &error);
 
+	/* This makes sure we don't steal all the system's resources */
+	initialize_priority ();
+
 	if (!filename && mime_type) {
 		gchar *help;
 

Modified: trunk/src/tracker-indexer/tracker-main.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-main.c	(original)
+++ trunk/src/tracker-indexer/tracker-main.c	Fri Mar 13 16:23:49 2009
@@ -52,13 +52,6 @@
 #include "tracker-indexer.h"
 #include "tracker-push.h"
 
-/* Temporary hack for out of date kernels, also, this value may not be
- * the same on all architectures, but it is for x86.
- */
-#ifndef SCHED_IDLE
-#define SCHED_IDLE 5
-#endif
-
 #define ABOUT								  \
 	"Tracker " PACKAGE_VERSION "\n"
 
@@ -201,8 +194,6 @@
 static void
 initialize_priority (void)
 {
-	struct sched_param sp;
-
 	/* Set disk IO priority and scheduling */
 	tracker_ioprio_init ();
 
@@ -221,28 +212,6 @@
 		g_message ("Couldn't set nice value to 19, %s",
 			   str ? str : "no error given");
 	}
-
-	/* Set process scheduling parameters:
-	 * This is used so we don't steal scheduling priority from
-	 * the most important applications - like the phone
-	 * application which has a real time requirement here. This
-	 * is detailed in Nokia bug #95573 
-	 */
-	g_message ("Setting scheduling priority");
-
-	if (sched_getparam (0, &sp) == 0) {
-		if (sched_setscheduler (0, SCHED_IDLE, &sp) != 0) {
-			const gchar *str = g_strerror (errno);
-			
-			g_message ("Couldn't set scheduler priority, %s",
-				   str ? str : "no error given");
-		}
-	} else {
-		const gchar *str = g_strerror (errno);
-
-		g_message ("Couldn't get scheduler priority, %s",
-			   str ? str : "no error given");
-	}
 }
 
 static gboolean

Modified: trunk/src/trackerd/tracker-main.c
==============================================================================
--- trunk/src/trackerd/tracker-main.c	(original)
+++ trunk/src/trackerd/tracker-main.c	Fri Mar 13 16:23:49 2009
@@ -78,13 +78,6 @@
 #include "mingw-compat.h"
 #endif
 
-/* Temporary hack for out of date kernels, also, this value may not be
- * the same on all architectures, but it is for x86.
- */
-#ifndef SCHED_IDLE
-#define SCHED_IDLE 5
-#endif
-
 #define ABOUT								  \
 	"Tracker " PACKAGE_VERSION "\n"
 



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