From 05e0ca51673774842b7156cfa6bbbcbb591fcdcb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 9 Feb 2010 22:43:36 +0000 Subject: make sure we run ALL shutdown tasks before resuming execution of new 'normal' tasks --- src/util/scheduler.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/util/scheduler.c') diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 6b12c7d1a..dfc751048 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -60,10 +60,9 @@ struct Task struct GNUNET_NETWORK_FDSet *read_set; /** - * Set of file descriptors this task is waiting - * for for writing. Once ready, this is updated - * to reflect the set of file descriptors ready - * for operation. + * Set of file descriptors this task is waiting for for writing. + * Once ready, this is updated to reflect the set of file + * descriptors ready for operation. */ struct GNUNET_NETWORK_FDSet *write_set; @@ -334,8 +333,11 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched, static void queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, struct Task *task) { - task->next = handle->ready[check_priority (task->priority)]; - handle->ready[check_priority (task->priority)] = task; + enum GNUNET_SCHEDULER_Priority p = task->priority; + if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) + p = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; + task->next = handle->ready[check_priority (p)]; + handle->ready[check_priority (p)] = task; handle->ready_count++; } @@ -472,7 +474,7 @@ 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 = p; + sched->current_priority = pos->priority; GNUNET_assert (pos->priority == p); sched->active_task = pos; tc.sched = sched; -- cgit v1.2.3