arm related changes to util things, enabling leaky sockets and shutdown messages...
[oweals/gnunet.git] / src / util / scheduler.c
index 7b6f86c9e894b74962c449ef6162d56d27f8e4ef..c46c895009e565f247de1efbbda22cf9a2cdf8cf 100644 (file)
  */
 #include "platform.h"
 #include "gnunet_common.h"
+#include "gnunet_os_lib.h"
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_signal_lib.h"
 #include "gnunet_time_lib.h"
 #ifdef LINUX
 #include "execinfo.h"
 #define EXECINFO GNUNET_NO
+#define MAX_TRACE_DEPTH 50
 #endif
 
 #define DEBUG_TASKS GNUNET_NO
@@ -166,6 +168,11 @@ struct GNUNET_SCHEDULER_Handle
    */
   enum GNUNET_SCHEDULER_Priority current_priority;
 
+  /**
+   * How 'nice' are we right now?
+   */
+  int nice_level;
+
 };
 
 
@@ -494,7 +501,11 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched)
       GNUNET_assert (pos != NULL);      /* ready_count wrong? */
       sched->ready[p] = pos->next;
       sched->ready_count--;
-      sched->current_priority = pos->priority;
+      if (sched->current_priority != pos->priority)
+       {
+         sched->current_priority = pos->priority;
+         (void) GNUNET_OS_set_process_priority (0, pos->priority);
+       }
       sched->active_task = pos;
       tc.sched = sched;
       tc.reason = pos->reason;
@@ -1095,13 +1106,15 @@ GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched,
 {
   struct Task *t;
 #if EXECINFO
-  void *backtrace_array[50];
+  void *backtrace_array[MAX_TRACE_DEPTH];
 #endif
+
+  GNUNET_assert (NULL != task);
   t = GNUNET_malloc (sizeof (struct Task));
   t->callback = task;
   t->callback_cls = task_cls;
 #if EXECINFO
-  t->num_backtrace_strings = backtrace(backtrace_array, 50);
+  t->num_backtrace_strings = backtrace(backtrace_array, MAX_TRACE_DEPTH);
   t->backtrace_strings = backtrace_symbols(backtrace_array, t->num_backtrace_strings);
 #endif
   if (rs != NULL)