diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-02-09 22:43:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-02-09 22:43:36 +0000 |
commit | 05e0ca51673774842b7156cfa6bbbcbb591fcdcb (patch) | |
tree | 7e67c7704e96937fe620ef54b6a385b86ef447bc | |
parent | f742e2048502ea164ea399ff9da727393ebcef8c (diff) | |
download | gnunet-05e0ca51673774842b7156cfa6bbbcbb591fcdcb.tar.gz gnunet-05e0ca51673774842b7156cfa6bbbcbb591fcdcb.zip |
make sure we run ALL shutdown tasks before resuming execution of new 'normal' tasks
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 12 | ||||
-rw-r--r-- | src/util/scheduler.c | 16 | ||||
-rw-r--r-- | src/util/server.c | 2 |
3 files changed, 21 insertions, 9 deletions
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index 3205729a3..79739ef16 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -142,10 +142,20 @@ enum GNUNET_SCHEDULER_Priority | |||
142 | GNUNET_SCHEDULER_PRIORITY_URGENT = 6, | 142 | GNUNET_SCHEDULER_PRIORITY_URGENT = 6, |
143 | 143 | ||
144 | /** | 144 | /** |
145 | * This is an internal priority level that is only used for tasks | ||
146 | * that are being triggered due to shutdown (they have automatically | ||
147 | * highest priority). User code must not use this priority level | ||
148 | * directly. Tasks run with this priority level that internally | ||
149 | * schedule other tasks will see their original priority level | ||
150 | * be inherited (unless otherwise specified). | ||
151 | */ | ||
152 | GNUNET_SCHEDULER_PRIORITY_SHUTDOWN = 7, | ||
153 | |||
154 | /** | ||
145 | * Number of priorities (must be the last priority). | 155 | * Number of priorities (must be the last priority). |
146 | * This priority must not be used by clients. | 156 | * This priority must not be used by clients. |
147 | */ | 157 | */ |
148 | GNUNET_SCHEDULER_PRIORITY_COUNT = 7 | 158 | GNUNET_SCHEDULER_PRIORITY_COUNT = 8 |
149 | }; | 159 | }; |
150 | 160 | ||
151 | #include "gnunet_time_lib.h" | 161 | #include "gnunet_time_lib.h" |
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, | |||
334 | static void | 333 | static void |
335 | queue_ready_task (struct GNUNET_SCHEDULER_Handle *handle, struct Task *task) | 334 | queue_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; |
diff --git a/src/util/server.c b/src/util/server.c index 62dea6d90..32008bce8 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -779,7 +779,7 @@ process_incoming (void *cls, | |||
779 | (client->shutdown_now == GNUNET_YES) || | 779 | (client->shutdown_now == GNUNET_YES) || |
780 | (GNUNET_YES != client->check (client->client_closure))) | 780 | (GNUNET_YES != client->check (client->client_closure))) |
781 | { | 781 | { |
782 | /* other side closed connection, error connecting, etc. */ | 782 | /* other side closed connection, error connecting, etc. */ |
783 | shutdown_incoming_processing (client); | 783 | shutdown_incoming_processing (client); |
784 | return; | 784 | return; |
785 | } | 785 | } |