*/
GNUNET_SCHEDULER_PRIORITY_URGENT = 6,
+ /**
+ * This is an internal priority level that is only used for tasks
+ * that are being triggered due to shutdown (they have automatically
+ * highest priority). User code must not use this priority level
+ * directly. Tasks run with this priority level that internally
+ * schedule other tasks will see their original priority level
+ * be inherited (unless otherwise specified).
+ */
+ GNUNET_SCHEDULER_PRIORITY_SHUTDOWN = 7,
+
/**
* Number of priorities (must be the last priority).
* This priority must not be used by clients.
*/
- GNUNET_SCHEDULER_PRIORITY_COUNT = 7
+ GNUNET_SCHEDULER_PRIORITY_COUNT = 8
};
#include "gnunet_time_lib.h"
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;
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++;
}
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;
(client->shutdown_now == GNUNET_YES) ||
(GNUNET_YES != client->check (client->client_closure)))
{
- /* other side closed connection, error connecting, etc. */
+ /* other side closed connection, error connecting, etc. */
shutdown_incoming_processing (client);
return;
}