aboutsummaryrefslogtreecommitdiff
path: root/src/util/scheduler.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-02-09 22:43:36 +0000
committerChristian Grothoff <christian@grothoff.org>2010-02-09 22:43:36 +0000
commit05e0ca51673774842b7156cfa6bbbcbb591fcdcb (patch)
tree7e67c7704e96937fe620ef54b6a385b86ef447bc /src/util/scheduler.c
parentf742e2048502ea164ea399ff9da727393ebcef8c (diff)
downloadgnunet-05e0ca51673774842b7156cfa6bbbcbb591fcdcb.tar.gz
gnunet-05e0ca51673774842b7156cfa6bbbcbb591fcdcb.zip
make sure we run ALL shutdown tasks before resuming execution of new 'normal' tasks
Diffstat (limited to 'src/util/scheduler.c')
-rw-r--r--src/util/scheduler.c16
1 files changed, 9 insertions, 7 deletions
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
60 struct GNUNET_NETWORK_FDSet *read_set; 60 struct GNUNET_NETWORK_FDSet *read_set;
61 61
62 /** 62 /**
63 * Set of file descriptors this task is waiting 63 * Set of file descriptors this task is waiting for for writing.
64 * for for writing. Once ready, this is updated 64 * Once ready, this is updated to reflect the set of file
65 * to reflect the set of file descriptors ready 65 * descriptors ready for operation.
66 * for operation.
67 */ 66 */
68 struct GNUNET_NETWORK_FDSet *write_set; 67 struct GNUNET_NETWORK_FDSet *write_set;
69 68
@@ -334,8 +333,11 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched,
334static void 333static void
335queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, struct Task *task) 334queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, struct Task *task)
336{ 335{
337 task->next = handle->ready[check_priority (task->priority)]; 336 enum GNUNET_SCHEDULER_Priority p = task->priority;
338 handle->ready[check_priority (task->priority)] = task; 337 if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
338 p = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN;
339 task->next = handle->ready[check_priority (p)];
340 handle->ready[check_priority (p)] = task;
339 handle->ready_count++; 341 handle->ready_count++;
340} 342}
341 343
@@ -472,7 +474,7 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched)
472 GNUNET_assert (pos != NULL); /* ready_count wrong? */ 474 GNUNET_assert (pos != NULL); /* ready_count wrong? */
473 sched->ready[p] = pos->next; 475 sched->ready[p] = pos->next;
474 sched->ready_count--; 476 sched->ready_count--;
475 sched->current_priority = p; 477 sched->current_priority = pos->priority;
476 GNUNET_assert (pos->priority == p); 478 GNUNET_assert (pos->priority == p);
477 sched->active_task = pos; 479 sched->active_task = pos;
478 tc.sched = sched; 480 tc.sched = sched;