GNUnet 0.26.2-16-ge86b66bd5
 
Loading...
Searching...
No Matches
Scheduler library

Event loop (scheduler) More...

Collaboration diagram for Scheduler library:

Data Structures

struct  GNUNET_SCHEDULER_FdInfo
 Information about an event relating to a file descriptor/socket. More...
 
struct  GNUNET_SCHEDULER_TaskContext
 Context information passed to each scheduler task. More...
 
struct  GNUNET_SCHEDULER_Driver
 API an external event loop has to implement for GNUNET_SCHEDULER_driver_init. More...
 

Typedefs

typedef void(* GNUNET_SCHEDULER_TaskCallback) (void *cls)
 Signature of the main function of a task.
 
typedef int(* GNUNET_SCHEDULER_select) (void *cls, struct GNUNET_NETWORK_FDSet *rfds, struct GNUNET_NETWORK_FDSet *wfds, struct GNUNET_NETWORK_FDSet *efds, struct GNUNET_TIME_Relative timeout)
 Signature of the select function used by the scheduler.
 

Enumerations

enum  GNUNET_SCHEDULER_Reason {
  GNUNET_SCHEDULER_REASON_NONE = 0 , GNUNET_SCHEDULER_REASON_STARTUP = 1 , GNUNET_SCHEDULER_REASON_SHUTDOWN = 2 , GNUNET_SCHEDULER_REASON_TIMEOUT = 4 ,
  GNUNET_SCHEDULER_REASON_READ_READY = 8 , GNUNET_SCHEDULER_REASON_WRITE_READY = 16 , GNUNET_SCHEDULER_REASON_PREREQ_DONE = 32
}
 Reasons why the schedule may have triggered the task now. More...
 
enum  GNUNET_SCHEDULER_EventType {
  GNUNET_SCHEDULER_ET_NONE = 0 , GNUNET_SCHEDULER_ET_IN = 1 , GNUNET_SCHEDULER_ET_OUT = 2 , GNUNET_SCHEDULER_ET_HUP = 4 ,
  GNUNET_SCHEDULER_ET_ERR = 8 , GNUNET_SCHEDULER_ET_PRI = 16 , GNUNET_SCHEDULER_ET_NVAL = 32
}
 Possible events on FDs, used as a bitmask. More...
 

Functions

void GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, struct GNUNET_SCHEDULER_FdInfo *fdi)
 Function used by event-loop implementations to signal the scheduler that a particular task is ready due to an event specified in the et field of fdi.
 
int GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh)
 Function called by external event loop implementations to tell the scheduler to run some of the tasks that are ready.
 
struct GNUNET_SCHEDULER_HandleGNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver)
 Function called by external event loop implementations to initialize the scheduler.
 
void GNUNET_SCHEDULER_driver_done (struct GNUNET_SCHEDULER_Handle *sh)
 Counter-part of GNUNET_SCHEDULER_driver_init.
 
struct GNUNET_SCHEDULER_DriverGNUNET_SCHEDULER_driver_select (void)
 Obtain the driver for using select() as the event loop.
 
void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Initialize and run scheduler.
 
void GNUNET_SCHEDULER_run_with_optional_signals (int install_signals, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Initialize and run scheduler.
 
void GNUNET_SCHEDULER_shutdown (void)
 Request the shutdown of a scheduler.
 
unsigned int GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p)
 Get information about the current load of this scheduler.
 
const struct GNUNET_SCHEDULER_TaskContextGNUNET_SCHEDULER_get_task_context (void)
 Obtain the reasoning why the current task was started.
 
void * GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task)
 Cancel the task with the specified identifier.
 
void GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback task, void *task_cls, enum GNUNET_SCHEDULER_Reason reason, enum GNUNET_SCHEDULER_Priority priority)
 Continue the current execution with the given function.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified priority.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run as soon as possible.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run as soon as possible with the (transitive) ignore-shutdown flag either explicitly set or explicitly enabled.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run at the specified time.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run at the specified time.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for reading.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified priority and to be run after the specified delay or when the specified file descriptor is ready for reading.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *wfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for writing.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, struct GNUNET_NETWORK_Handle *fd, int on_read, int on_write, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay or when the specified file descriptor is ready.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for reading.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *wfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for writing.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, const struct GNUNET_DISK_FileHandle *fd, int on_read, int on_write, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay or when the specified file descriptor is ready.
 
struct GNUNET_SCHEDULER_TaskGNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
 Schedule a new task to be run with a specified delay or when any of the specified file descriptor sets is ready.
 
void GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select, void *new_select_cls)
 Sets the select function to use in the scheduler (scheduler_select).
 
void GNUNET_SCHEDULER_begin_async_scope (struct GNUNET_AsyncScopeId *aid)
 Change the async scope for the currently executing task and (transitively) for all tasks scheduled by the current task after calling this function.
 

Detailed Description

Event loop (scheduler)

Schedule computations using continuation passing style.

Typedef Documentation

◆ GNUNET_SCHEDULER_TaskCallback

typedef void(* GNUNET_SCHEDULER_TaskCallback) (void *cls)

Signature of the main function of a task.

Parameters
clsclosure

Definition at line 323 of file gnunet_scheduler_lib.h.

◆ GNUNET_SCHEDULER_select

typedef int(* GNUNET_SCHEDULER_select) (void *cls, struct GNUNET_NETWORK_FDSet *rfds, struct GNUNET_NETWORK_FDSet *wfds, struct GNUNET_NETWORK_FDSet *efds, struct GNUNET_TIME_Relative timeout)

Signature of the select function used by the scheduler.

GNUNET_NETWORK_socket_select matches it.

Parameters
clsclosure
rfdsset of sockets to be checked for readability
wfdsset of sockets to be checked for writability
efdsset of sockets to be checked for exceptions
timeoutrelative value when to return
Returns
number of selected sockets, GNUNET_SYSERR on error

Definition at line 400 of file gnunet_scheduler_lib.h.

Enumeration Type Documentation

◆ GNUNET_SCHEDULER_Reason

Reasons why the schedule may have triggered the task now.

Enumerator
GNUNET_SCHEDULER_REASON_NONE 

This task is not ready.

GNUNET_SCHEDULER_REASON_STARTUP 

This is the very first task run during startup.

GNUNET_SCHEDULER_REASON_SHUTDOWN 

We are shutting down and are running all shutdown-related tasks.

GNUNET_SCHEDULER_REASON_TIMEOUT 

The specified timeout has expired.

(also set if the delay given was 0).

GNUNET_SCHEDULER_REASON_READ_READY 

The reading socket is ready.

GNUNET_SCHEDULER_REASON_WRITE_READY 

The writing socket is ready.

GNUNET_SCHEDULER_REASON_PREREQ_DONE 

The prerequisite task is done.

Definition at line 59 of file gnunet_scheduler_lib.h.

60{
65
70
75
81
86
91
96};
@ GNUNET_SCHEDULER_REASON_TIMEOUT
The specified timeout has expired.
@ GNUNET_SCHEDULER_REASON_READ_READY
The reading socket is ready.
@ GNUNET_SCHEDULER_REASON_SHUTDOWN
We are shutting down and are running all shutdown-related tasks.
@ GNUNET_SCHEDULER_REASON_NONE
This task is not ready.
@ GNUNET_SCHEDULER_REASON_STARTUP
This is the very first task run during startup.
@ GNUNET_SCHEDULER_REASON_WRITE_READY
The writing socket is ready.
@ GNUNET_SCHEDULER_REASON_PREREQ_DONE
The prerequisite task is done.

◆ GNUNET_SCHEDULER_EventType

Possible events on FDs, used as a bitmask.

Modelled after GPollFD.

Enumerator
GNUNET_SCHEDULER_ET_NONE 

No event (useful for timeout).

GNUNET_SCHEDULER_ET_IN 

Data available for reading.

GNUNET_SCHEDULER_ET_OUT 

Buffer available for writing.

GNUNET_SCHEDULER_ET_HUP 
GNUNET_SCHEDULER_ET_ERR 
GNUNET_SCHEDULER_ET_PRI 
GNUNET_SCHEDULER_ET_NVAL 

Definition at line 108 of file gnunet_scheduler_lib.h.

109{
114
119
124
129
134
139
144};
@ GNUNET_SCHEDULER_ET_OUT
Buffer available for writing.
@ GNUNET_SCHEDULER_ET_HUP
@ GNUNET_SCHEDULER_ET_NONE
No event (useful for timeout).
@ GNUNET_SCHEDULER_ET_NVAL
@ GNUNET_SCHEDULER_ET_IN
Data available for reading.
@ GNUNET_SCHEDULER_ET_PRI
@ GNUNET_SCHEDULER_ET_ERR

Function Documentation

◆ GNUNET_SCHEDULER_task_ready()

void GNUNET_SCHEDULER_task_ready ( struct GNUNET_SCHEDULER_Task task,
struct GNUNET_SCHEDULER_FdInfo fdi 
)

Function used by event-loop implementations to signal the scheduler that a particular task is ready due to an event specified in the et field of fdi.

This function will then queue the task to notify the application that the task is ready (with the respective priority).

Parameters
taskthe task that is ready
fdiinformation about the related FD

Definition at line 1960 of file scheduler.c.

1962{
1963 enum GNUNET_SCHEDULER_Reason reason;
1964
1965 reason = task->reason;
1966 if ((0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
1967 (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et)))
1969 if ((0 == (reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) &&
1970 (0 != (GNUNET_SCHEDULER_ET_OUT & fdi->et)))
1973 task->reason = reason;
1974 if (GNUNET_NO == task->in_ready_list)
1975 {
1978 task);
1979 queue_ready_task (task);
1980 }
1981}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_NO
GNUNET_SCHEDULER_Reason
Reasons why the schedule may have triggered the task now.
static void queue_ready_task(struct GNUNET_SCHEDULER_Task *task)
Put a task that is ready for execution into the ready queue.
Definition scheduler.c:551
static struct GNUNET_SCHEDULER_Task * pending_head
Head of list of tasks waiting for an event.
Definition scheduler.c:329
static struct GNUNET_SCHEDULER_Task * pending_tail
Tail of list of tasks waiting for an event.
Definition scheduler.c:334
enum GNUNET_SCHEDULER_EventType et
Type of the event that was generated related to sock.
int in_ready_list
Is this task in the ready list?
Definition scheduler.c:235
enum GNUNET_SCHEDULER_Reason reason
Why is the task ready? Set after task is added to ready queue.
Definition scheduler.c:204

References GNUNET_SCHEDULER_FdInfo::et, GNUNET_CONTAINER_DLL_remove, GNUNET_NO, GNUNET_SCHEDULER_ET_IN, GNUNET_SCHEDULER_ET_OUT, GNUNET_SCHEDULER_REASON_PREREQ_DONE, GNUNET_SCHEDULER_REASON_READ_READY, GNUNET_SCHEDULER_REASON_WRITE_READY, GNUNET_SCHEDULER_Task::in_ready_list, pending_head, pending_tail, queue_ready_task(), and GNUNET_SCHEDULER_Task::reason.

Referenced by select_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_do_work()

int GNUNET_SCHEDULER_do_work ( struct GNUNET_SCHEDULER_Handle sh)

Function called by external event loop implementations to tell the scheduler to run some of the tasks that are ready.

Must be called only after GNUNET_SCHEDULER_driver_init has been called and before GNUNET_SCHEDULER_driver_done is called. This function may return even though there are tasks left to run just to give other tasks a chance as well. If we return GNUNET_YES, the event loop implementation should call this function again as soon as possible, while if we return GNUNET_NO it must block until either the operating system has more work (the scheduler has no more work to do right now) or the timeout set by the scheduler (using the set_wakeup callback) is reached.

Parameters
shscheduler handle that was returned by GNUNET_SCHEDULER_driver_init
Returns
GNUNET_YES if there are more tasks that are ready, and thus we would like to run more (yield to avoid blocking other activities for too long) GNUNET_NO if we are done running tasks (yield to block)

The event loop called this function before the current timeout was reached (and no FD tasks are ready). This is acceptable if

  • the system time was changed while the driver was waiting for the timeout
  • an external event loop called GNUnet API functions outside of the callbacks called in GNUNET_SCHEDULER_do_work and thus wasn't notified about the new timeout

It might also mean we are busy-waiting because of a programming error in the external event loop.

the current timeout was reached but no ready tasks were found, internal scheduler error!

Definition at line 2005 of file scheduler.c.

2006{
2007 struct GNUNET_SCHEDULER_Task *pos;
2008 struct GNUNET_TIME_Absolute now;
2009
2010 /* check for tasks that reached the timeout! */
2011 now = GNUNET_TIME_absolute_get ();
2013 while (NULL != pos)
2014 {
2015 struct GNUNET_SCHEDULER_Task *next = pos->next;
2016 if (now.abs_value_us >= pos->timeout.abs_value_us)
2018 if (0 == pos->reason)
2019 break;
2022 pos);
2023 if (pending_timeout_last == pos)
2024 pending_timeout_last = NULL;
2025 queue_ready_task (pos);
2026 pos = next;
2027 }
2028 pos = pending_head;
2029 while (NULL != pos)
2030 {
2031 struct GNUNET_SCHEDULER_Task *next = pos->next;
2032 if (now.abs_value_us >= pos->timeout.abs_value_us)
2033 {
2037 pos);
2038 queue_ready_task (pos);
2039 }
2040 pos = next;
2041 }
2042
2043 if (0 == ready_count)
2044 {
2046
2047 if (timeout.abs_value_us > now.abs_value_us)
2048 {
2063 "GNUNET_SCHEDULER_do_work did not find any ready "
2064 "tasks and timeout has not been reached yet.\n");
2065 }
2066 else
2067 {
2072 GNUNET_assert (0);
2073 }
2074 }
2075 else
2076 {
2077 /* find out which task priority level we are going to
2078 process this time */
2081 /* yes, p>0 is correct, 0 is "KEEP" which should
2082 * always be an empty queue (see assertion)! */
2084 work_priority > 0;
2085 work_priority--)
2086 {
2088 if (NULL != pos)
2089 break;
2090 }
2091 GNUNET_assert (NULL != pos); /* ready_count wrong? */
2092
2093 /* process all *existing* tasks at this priority
2094 level, then yield */
2096 while (NULL != (pos = ready_head[work_priority])
2097 && pos != &pass_end_marker)
2098 {
2101 pos);
2102 ready_count--;
2105 active_task = pos;
2106#if PROFILE_DELAYS
2107 if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value_us >
2108 DELAY_THRESHOLD.rel_value_us)
2109 {
2111 "Task %p took %s to be scheduled\n",
2112 pos,
2114 GNUNET_TIME_absolute_get_duration (pos->start_time),
2115 GNUNET_YES));
2116 }
2117#endif
2118 tc.reason = pos->reason;
2121 // FIXME: do we have to remove FdInfos from fds if they are not ready?
2122 tc.fds_len = pos->fds_len;
2123 tc.fds = pos->fds;
2124 for (unsigned int i = 0; i != pos->fds_len; ++i)
2125 {
2126 struct GNUNET_SCHEDULER_FdInfo *fdi = &pos->fds[i];
2127 if (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et))
2128 {
2130 fdi->sock);
2131 }
2132 if (0 != (GNUNET_SCHEDULER_ET_OUT & fdi->et))
2133 {
2135 fdi->sock);
2136 }
2137 }
2138 tc.read_ready = sh->rs;
2139 tc.write_ready = sh->ws;
2140#if EXTRA_DEBUG
2142 "Running task %p\n",
2143 pos);
2144#endif
2145 GNUNET_assert (NULL != pos->callback);
2146 {
2147 struct GNUNET_AsyncScopeSave old_scope;
2148 if (pos->scope.have_scope)
2149 GNUNET_async_scope_enter (&pos->scope.scope_id, &old_scope);
2150 else
2151 GNUNET_async_scope_get (&old_scope);
2152 pos->callback (pos->callback_cls);
2153 GNUNET_async_scope_restore (&old_scope);
2154 }
2155 if (NULL != pos->fds)
2156 {
2157 int del_result = scheduler_driver->del (scheduler_driver->cls,
2158 pos);
2159 if (GNUNET_OK != del_result)
2160 {
2162 "driver could not delete task %p\n", pos);
2163 GNUNET_assert (0);
2164 }
2165 }
2166 active_task = NULL;
2167 dump_backtrace (pos);
2168 destroy_task (pos);
2169 }
2171 }
2173 if (0 == ready_count)
2174 {
2176 get_timeout ());
2177 return GNUNET_NO;
2178 }
2181 return GNUNET_YES;
2182}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition gnunet-arm.c:118
static struct GNUNET_IDENTITY_Handle * sh
Handle to IDENTITY service.
void GNUNET_async_scope_enter(const struct GNUNET_AsyncScopeId *aid, struct GNUNET_AsyncScopeSave *old_scope)
Set the async scope for the current thread.
int have_scope
GNUNET_YES unless this saved scope is the unnamed root scope.
void GNUNET_async_scope_get(struct GNUNET_AsyncScopeSave *scope_ret)
Get the current async scope.
void GNUNET_async_scope_restore(struct GNUNET_AsyncScopeSave *old_scope)
Clear the current thread's async scope.
struct GNUNET_AsyncScopeId scope_id
Saved scope.
@ GNUNET_SCHEDULER_PRIORITY_COUNT
Number of priorities (must be the last priority).
@ GNUNET_SCHEDULER_PRIORITY_KEEP
Run with the same priority as the current job.
@ GNUNET_OK
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_NETWORK_fdset_zero(struct GNUNET_NETWORK_FDSet *fds)
Reset FD set (clears all file descriptors).
Definition network.c:918
void GNUNET_NETWORK_fdset_set_native(struct GNUNET_NETWORK_FDSet *to, int nfd)
Set a native fd in a set.
Definition network.c:1058
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition strings.c:604
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
static void dump_backtrace(struct GNUNET_SCHEDULER_Task *t)
Output stack trace of task t.
Definition scheduler.c:605
static void destroy_task(struct GNUNET_SCHEDULER_Task *t)
Destroy a task (release associated resources)
Definition scheduler.c:626
static struct GNUNET_SCHEDULER_Task * active_task
ID of the task that is running right now.
Definition scheduler.c:373
static struct GNUNET_SCHEDULER_Task * ready_tail[GNUNET_SCHEDULER_PRIORITY_COUNT]
Tail of list of tasks ready to run right now, grouped by importance.
Definition scheduler.c:384
static enum GNUNET_SCHEDULER_Priority current_priority
Priority of the task running right now.
Definition scheduler.c:409
static struct GNUNET_TIME_Absolute get_timeout()
chooses the nearest timeout from all pending tasks, to be used to tell the driver the next wakeup tim...
Definition scheduler.c:482
static void remove_pass_end_marker()
Definition scheduler.c:520
#define DELAY_THRESHOLD
Task that were in the queue for longer than this are reported if PROFILE_DELAYS is active.
Definition scheduler.c:79
static unsigned int ready_count
Number of tasks on the ready list.
Definition scheduler.c:403
static const struct GNUNET_SCHEDULER_Driver * scheduler_driver
The driver used for the event loop.
Definition scheduler.c:324
static struct GNUNET_SCHEDULER_Task * pending_timeout_head
List of tasks waiting ONLY for a timeout event.
Definition scheduler.c:353
static enum GNUNET_SCHEDULER_Priority work_priority
Priority used currently in GNUNET_SCHEDULER_do_work().
Definition scheduler.c:425
static void shutdown_if_no_lifeness(void)
Definition scheduler.c:705
static struct GNUNET_SCHEDULER_Task * pending_timeout_tail
List of tasks waiting ONLY for a timeout event.
Definition scheduler.c:362
static struct GNUNET_SCHEDULER_Task * ready_head[GNUNET_SCHEDULER_PRIORITY_COUNT]
Head of list of tasks ready to run right now, grouped by importance.
Definition scheduler.c:378
static struct GNUNET_SCHEDULER_Task pass_end_marker
Placed at the end of a ready queue to indicate where a scheduler run pass ends.
Definition scheduler.c:261
static int current_lifeness
Value of the 'lifeness' flag for the current task.
Definition scheduler.c:420
static void set_work_priority(enum GNUNET_SCHEDULER_Priority p)
Definition scheduler.c:533
static enum GNUNET_SCHEDULER_Priority max_priority_added
Priority of the highest task added in the current select iteration.
Definition scheduler.c:415
static struct GNUNET_SCHEDULER_Task * pending_timeout_last
Last inserted task waiting ONLY for a timeout event.
Definition scheduler.c:368
#define LOG(kind,...)
Definition scheduler.c:37
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition scheduler.c:436
Saved async scope identifier or root scope.
void * cls
Closure to pass to the functions in this struct.
void(* set_wakeup)(void *cls, struct GNUNET_TIME_Absolute dt)
Set time at which we definitively want to get a wakeup call.
int(* del)(void *cls, struct GNUNET_SCHEDULER_Task *task)
Delete a task from the set of tasks to be run.
Information about an event relating to a file descriptor/socket.
int sock
Underlying OS handle the event was about.
const struct GNUNET_NETWORK_FDSet * read_ready
Set of file descriptors ready for reading; note that additional bits may be set that were not in the ...
enum GNUNET_SCHEDULER_Reason reason
Reason why the task is run now.
unsigned int fds_len
Length of the following array.
const struct GNUNET_SCHEDULER_FdInfo * fds
Array of length fds_len with information about ready FDs.
const struct GNUNET_NETWORK_FDSet * write_ready
Set of file descriptors ready for writing; note that additional bits may be set that were not in the ...
Entry in list of pending tasks.
Definition scheduler.c:141
enum GNUNET_SCHEDULER_Priority priority
Task priority.
Definition scheduler.c:209
void * callback_cls
Closure for the callback.
Definition scheduler.c:160
int lifeness
Should the existence of this task in the queue be counted as reason to not shutdown the scheduler?
Definition scheduler.c:225
struct GNUNET_AsyncScopeSave scope
Asynchronous scope of the task that scheduled this scope,.
Definition scheduler.c:253
struct GNUNET_SCHEDULER_Task * next
This is a linked list.
Definition scheduler.c:145
struct GNUNET_SCHEDULER_FdInfo * fds
Information about which FDs are ready for this task (and why).
Definition scheduler.c:165
unsigned int fds_len
Size of the fds array.
Definition scheduler.c:177
struct GNUNET_TIME_Absolute timeout
Absolute timeout value for the task, or GNUNET_TIME_UNIT_FOREVER_ABS for "no timeout".
Definition scheduler.c:190
GNUNET_SCHEDULER_TaskCallback callback
Function to run when ready.
Definition scheduler.c:155
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
uint64_t rel_value_us
The actual value.

References GNUNET_TIME_Absolute::abs_value_us, active_task, GNUNET_SCHEDULER_Task::callback, GNUNET_SCHEDULER_Task::callback_cls, GNUNET_SCHEDULER_Driver::cls, current_lifeness, current_priority, GNUNET_SCHEDULER_Driver::del, DELAY_THRESHOLD, destroy_task(), dump_backtrace(), GNUNET_SCHEDULER_FdInfo::et, GNUNET_SCHEDULER_TaskContext::fds, GNUNET_SCHEDULER_Task::fds, GNUNET_SCHEDULER_TaskContext::fds_len, GNUNET_SCHEDULER_Task::fds_len, get_timeout(), GNUNET_assert, GNUNET_async_scope_enter(), GNUNET_async_scope_get(), GNUNET_async_scope_restore(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_NETWORK_fdset_set_native(), GNUNET_NETWORK_fdset_zero(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_ET_IN, GNUNET_SCHEDULER_ET_OUT, GNUNET_SCHEDULER_PRIORITY_COUNT, GNUNET_SCHEDULER_PRIORITY_KEEP, GNUNET_SCHEDULER_REASON_TIMEOUT, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, GNUNET_AsyncScopeSave::have_scope, GNUNET_SCHEDULER_Task::lifeness, LOG, max_priority_added, GNUNET_SCHEDULER_Task::next, pass_end_marker, pending_head, pending_tail, pending_timeout_head, pending_timeout_last, pending_timeout_tail, GNUNET_SCHEDULER_Task::priority, queue_ready_task(), GNUNET_SCHEDULER_TaskContext::read_ready, ready_count, ready_head, ready_tail, GNUNET_SCHEDULER_TaskContext::reason, GNUNET_SCHEDULER_Task::reason, GNUNET_TIME_Relative::rel_value_us, remove_pass_end_marker(), scheduler_driver, GNUNET_SCHEDULER_Task::scope, GNUNET_AsyncScopeSave::scope_id, GNUNET_SCHEDULER_Driver::set_wakeup, set_work_priority(), sh, shutdown_if_no_lifeness(), GNUNET_SCHEDULER_FdInfo::sock, tc, timeout, GNUNET_SCHEDULER_Task::timeout, work_priority, and GNUNET_SCHEDULER_TaskContext::write_ready.

Referenced by select_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_driver_init()

struct GNUNET_SCHEDULER_Handle * GNUNET_SCHEDULER_driver_init ( const struct GNUNET_SCHEDULER_Driver driver)

Function called by external event loop implementations to initialize the scheduler.

An external implementation has to provide driver which contains callbacks for the scheduler (see definition of struct GNUNET_SCHEDULER_Driver). The callbacks are used to instruct the external implementation to watch for events. If it detects any of those events it is expected to call GNUNET_SCHEDULER_do_work to let the scheduler handle it. If an event is related to a specific task (e.g. the scheduler gave instructions to watch a file descriptor), the external implementation is expected to mark that task ready before by calling GNUNET_SCHEDULER_task_ready.

This function has to be called before any tasks are scheduled and before GNUNET_SCHEDULER_do_work is called for the first time. It allocates resources that have to be freed again by calling GNUNET_SCHEDULER_driver_done.

This function installs the same signal handlers as GNUNET_SCHEDULER_run. This means SIGTERM (and other similar signals) will induce a call to GNUNET_SCHEDULER_shutdown during the next call to GNUNET_SCHEDULER_do_work. As a result, SIGTERM causes all active tasks to be scheduled with reason GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added afterwards will execute normally!). Note that any particular signal will only shut down one scheduler; applications should always only create a single scheduler.

Parameters
driverto use for the event loop
Returns
handle to be passed to GNUNET_SCHEDULER_do_work and GNUNET_SCHEDULER_driver_done

Definition at line 2217 of file scheduler.c.

2218{
2220 const struct GNUNET_DISK_FileHandle *pr;
2221
2222 /* scheduler must not be running */
2225 /* general set-up */
2231 my_pid = getpid ();
2232 scheduler_driver = driver;
2233
2234 /* install signal handlers */
2236 "Registering signal handlers\n");
2237 sh->shc_int = GNUNET_SIGNAL_handler_install (SIGINT,
2239 sh->shc_term = GNUNET_SIGNAL_handler_install (SIGTERM,
2241#if (SIGTERM != GNUNET_TERM_SIG)
2244#endif
2245 sh->shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE,
2247 sh->shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT,
2249 sh->shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP,
2251
2252 /* Setup initial tasks */
2255 /* ensure this task runs first, by using a priority level reserved for
2256 the scheduler (not really shutdown, but start-up ;-) */
2260 NULL);
2263 pr,
2265 NULL);
2268 get_timeout ());
2269 /* begin main event loop */
2273 return sh;
2274}
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
Get the handle to a particular pipe end.
Definition disk.c:1702
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe(enum GNUNET_DISK_PipeFlags pf)
Creates an interprocess channel.
Definition disk.c:1523
@ GNUNET_DISK_PF_NONE
No special options, use non-blocking read/write operations.
@ GNUNET_DISK_PIPE_END_READ
The reading-end of a pipe.
@ GNUNET_SCHEDULER_PRIORITY_DEFAULT
Run with the default priority (normal P2P operations).
@ GNUNET_SCHEDULER_PRIORITY_SHUTDOWN
This is an internal priority level that is only used for tasks that are being triggered due to shutdo...
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
Definition network.c:1169
void GNUNET_NETWORK_fdset_handle_set(struct GNUNET_NETWORK_FDSet *fds, const struct GNUNET_DISK_FileHandle *h)
Add a file handle to the fd set.
Definition network.c:1092
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition scheduler.c:1667
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition scheduler.c:1237
struct GNUNET_SIGNAL_Context * GNUNET_SIGNAL_handler_install(int signal, GNUNET_SIGNAL_Handler handler)
Install a signal handler that will be run if the given signal is received.
Definition signal.c:52
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TERM_SIG
The termination signal.
Definition platform.h:235
static void sighandler_pipe()
Signal handler called for SIGPIPE.
Definition scheduler.c:678
static struct GNUNET_SCHEDULER_Task * shutdown_pipe_task
Task for reading from a pipe that signal handlers will use to initiate shutdown.
Definition scheduler.c:398
static struct GNUNET_SCHEDULER_Task * install_parent_control_task
Task for installing parent control handlers (it might happen that the scheduler is shutdown before th...
Definition scheduler.c:392
static struct GNUNET_DISK_PipeHandle * shutdown_pipe_handle
Pipe used to communicate shutdown via signal.
Definition scheduler.c:666
static void install_parent_control_handler(void *cls)
Definition scheduler.c:942
static void sighandler_shutdown(void)
Signal handler called for signals that should cause us to shutdown.
Definition scheduler.c:688
static void shutdown_pipe_cb(void *cls)
Definition scheduler.c:951
static pid_t my_pid
Process ID of this process at the time we installed the various signal handlers.
Definition scheduler.c:672
Handle used to access files (and pipes).
Argument to be passed from the driver to GNUNET_SCHEDULER_do_work().
Definition scheduler.c:88

References GNUNET_SCHEDULER_Driver::cls, current_lifeness, current_priority, get_timeout(), GNUNET_assert, GNUNET_DISK_PF_NONE, GNUNET_DISK_pipe(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_handle_set(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_PRIORITY_SHUTDOWN, GNUNET_SIGNAL_handler_install(), GNUNET_TERM_SIG, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, install_parent_control_handler(), install_parent_control_task, LOG, my_pid, scheduler_driver, GNUNET_SCHEDULER_Driver::set_wakeup, sh, shutdown_pipe_cb(), shutdown_pipe_handle, shutdown_pipe_task, sighandler_pipe(), and sighandler_shutdown().

Referenced by GNUNET_SCHEDULER_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_driver_done()

void GNUNET_SCHEDULER_driver_done ( struct GNUNET_SCHEDULER_Handle sh)

Counter-part of GNUNET_SCHEDULER_driver_init.

Has to be called by external event loop implementations after the scheduler has shut down. This is the case if both of the following conditions are met:

  • all tasks the scheduler has added through the driver's add callback have been removed again through the driver's del callback
  • the timeout the scheduler has set through the driver's add_wakeup callback is FOREVER
Parameters
shthe handle returned by GNUNET_SCHEDULER_driver_init

Definition at line 2292 of file scheduler.c.

2293{
2294 GNUNET_break (NULL == pending_head);
2296 GNUNET_break (NULL == shutdown_head);
2297 for (int i = 0; i != GNUNET_SCHEDULER_PRIORITY_COUNT; ++i)
2298 {
2299 GNUNET_break (NULL == ready_head[i]);
2300 }
2303
2304 /* uninstall signal handlers */
2307#if (SIGTERM != GNUNET_TERM_SIG)
2309#endif
2314 shutdown_pipe_handle = NULL;
2315 scheduler_driver = NULL;
2316 GNUNET_free (sh);
2317}
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p)
Closes an interprocess channel.
Definition disk.c:1670
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
Definition network.c:1185
void GNUNET_SIGNAL_handler_uninstall(struct GNUNET_SIGNAL_Context *ctx)
Uninstall a previously installed signal handler.
Definition signal.c:78
static struct GNUNET_SCHEDULER_Task * shutdown_head
Head of list of tasks waiting for shutdown.
Definition scheduler.c:339

References GNUNET_break, GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_NETWORK_fdset_destroy(), GNUNET_SCHEDULER_PRIORITY_COUNT, GNUNET_SIGNAL_handler_uninstall(), pending_head, pending_timeout_head, ready_head, scheduler_driver, sh, shutdown_head, and shutdown_pipe_handle.

Referenced by GNUNET_SCHEDULER_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_driver_select()

struct GNUNET_SCHEDULER_Driver * GNUNET_SCHEDULER_driver_select ( void  )

Obtain the driver for using select() as the event loop.

Returns
NULL on error

Definition at line 2558 of file scheduler.c.

2559{
2560 struct GNUNET_SCHEDULER_Driver *select_driver;
2561
2562 select_driver = GNUNET_new (struct GNUNET_SCHEDULER_Driver);
2563
2564 select_driver->add = &select_add;
2565 select_driver->del = &select_del;
2566 select_driver->set_wakeup = &select_set_wakeup;
2567
2568 return select_driver;
2569}
static void select_set_wakeup(void *cls, struct GNUNET_TIME_Absolute dt)
Definition scheduler.c:2542
static int select_del(void *cls, struct GNUNET_SCHEDULER_Task *task)
Definition scheduler.c:2512
static int select_add(void *cls, struct GNUNET_SCHEDULER_Task *task, struct GNUNET_SCHEDULER_FdInfo *fdi)
Definition scheduler.c:2480
API an external event loop has to implement for GNUNET_SCHEDULER_driver_init.
int(* add)(void *cls, struct GNUNET_SCHEDULER_Task *task, struct GNUNET_SCHEDULER_FdInfo *fdi)
Add a task to be run if the conditions specified in the et field of the given fdi are satisfied.

References GNUNET_SCHEDULER_Driver::add, GNUNET_SCHEDULER_Driver::del, GNUNET_new, select_add(), select_del(), select_set_wakeup(), and GNUNET_SCHEDULER_Driver::set_wakeup.

Referenced by GNUNET_SCHEDULER_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_run()

void GNUNET_SCHEDULER_run ( GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Initialize and run scheduler.

This function will return when all tasks have completed. On systems with signals, receiving a SIGTERM (and other similar signals) will cause GNUNET_SCHEDULER_shutdown to be run after the active task is complete. As a result, SIGTERM causes all shutdown tasks to be scheduled with reason GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added afterwards will execute normally!). Note that any particular signal will only shut down one scheduler; applications should always only create a single scheduler.

Parameters
tasktask to run first (and immediately)
task_clsclosure of task

Definition at line 731 of file scheduler.c.

733{
735 struct GNUNET_SCHEDULER_Driver *driver;
736 struct DriverContext context = {
737 .scheduled_head = NULL,
738 .scheduled_tail = NULL,
739 .timeout = GNUNET_TIME_absolute_get ()
740 };
741
743 driver->cls = &context;
746 task_cls,
751 &context));
753 GNUNET_free (driver);
754}
static pa_context * context
Pulseaudio context.
void GNUNET_SCHEDULER_driver_done(struct GNUNET_SCHEDULER_Handle *sh)
Counter-part of GNUNET_SCHEDULER_driver_init.
Definition scheduler.c:2292
void GNUNET_SCHEDULER_add_with_reason_and_priority(GNUNET_SCHEDULER_TaskCallback task, void *task_cls, enum GNUNET_SCHEDULER_Reason reason, enum GNUNET_SCHEDULER_Priority priority)
Continue the current execution with the given function.
Definition scheduler.c:1080
struct GNUNET_SCHEDULER_Driver * GNUNET_SCHEDULER_driver_select()
Obtain the driver for using select() as the event loop.
Definition scheduler.c:2558
struct GNUNET_SCHEDULER_Handle * GNUNET_SCHEDULER_driver_init(const struct GNUNET_SCHEDULER_Driver *driver)
Function called by external event loop implementations to initialize the scheduler.
Definition scheduler.c:2217
static enum GNUNET_GenericReturnValue select_loop(struct GNUNET_SCHEDULER_Handle *sh, struct DriverContext *context)
Definition scheduler.c:2321
Driver context used by GNUNET_SCHEDULER_run.
Definition scheduler.c:296
struct Scheduled * scheduled_head
the head of a DLL containing information about the events the select driver is waiting for
Definition scheduler.c:301

References GNUNET_SCHEDULER_Driver::cls, context, GNUNET_break, GNUNET_free, GNUNET_OK, GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SCHEDULER_driver_done(), GNUNET_SCHEDULER_driver_init(), GNUNET_SCHEDULER_driver_select(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_REASON_STARTUP, GNUNET_TIME_absolute_get(), DriverContext::scheduled_head, select_loop(), and sh.

Referenced by GNUNET_DAEMON_main(), GNUNET_PROGRAM_monolith_main(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_main(), GNUNET_SERVICE_run_(), GNUNET_TESTING_main(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_run_with_optional_signals()

void GNUNET_SCHEDULER_run_with_optional_signals ( int  install_signals,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Initialize and run scheduler.

This function will return when all tasks have completed. When @ install_signals is GNUNET_YES, then this function behaves in the same was as GNUNET_SCHEDULER_run does. If @ install_signals is GNUNET_NO then no signal handlers are installed.

Parameters
install_signalswhether to install signals (GNUNET_YES/NO)
tasktask to run first (and immediately)
task_clsclosure of task

◆ GNUNET_SCHEDULER_shutdown()

void GNUNET_SCHEDULER_shutdown ( void  )

Request the shutdown of a scheduler.

Marks all tasks awaiting shutdown as ready. Note that tasks scheduled with GNUNET_SCHEDULER_add_shutdown() AFTER this call will be delayed until the next shutdown signal.

Definition at line 572 of file scheduler.c.

573{
574 struct GNUNET_SCHEDULER_Task *pos;
575
577 "GNUNET_SCHEDULER_shutdown\n");
578 if (NULL != install_parent_control_task)
579 {
582 }
583 if (NULL != shutdown_pipe_task)
584 {
586 shutdown_pipe_task = NULL;
587 }
588 while (NULL != (pos = shutdown_head))
589 {
592 pos);
594 queue_ready_task (pos);
595 }
596}
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
static struct GNUNET_SCHEDULER_Task * shutdown_tail
Tail of list of tasks waiting for shutdown.
Definition scheduler.c:344

References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_REASON_SHUTDOWN, install_parent_control_task, LOG, queue_ready_task(), GNUNET_SCHEDULER_Task::reason, shutdown_head, shutdown_pipe_task, and shutdown_tail.

Referenced by action_loop(), add_continuation(), add_continuation(), add_continuation(), allocation_cb(), bandwidth_stats_cont(), calculate_pow(), channel_ended(), cleanup(), cleanup(), conn_status(), connect_check_run(), core_init(), core_init(), delay_shutdown(), delegation_store_cont(), dht_connected(), directory_scan_cb(), directory_trim_complete(), do_get(), do_quit(), do_send(), do_shutdown(), do_timeout(), do_timeout(), do_timeout(), ego_callback(), env_resign_cb(), error_cb(), find_proof(), finish_command(), GCD_init(), get_cb(), get_ego(), handle_block(), handle_collect_result(), handle_data(), handle_estimate(), handle_helper_barrier_crossable(), handle_helper_init(), handle_result(), handle_revocation_union_request(), handle_stop(), handle_verify_result(), hello_done_cb(), hello_iter(), hello_result_cb(), hello_store_success(), identity_cb(), identity_cb(), identity_cb(), identity_changed(), identity_continuation(), init_callback(), init_socket(), init_socket(), list_callback(), load_ikm(), load_ikm(), load_ikm(), main_init(), missing_zone_creation_cont(), monitor_cb(), nat_register(), on_identity(), operation_timeout(), origin_create_cb(), output_parser(), parse(), path_callback(), peers_callback(), pid_change_cb(), pid_changed_cb(), print_finish(), print_indexed(), print_query_result(), print_revocation_result(), process_command_stdin(), process_lookup_result(), process_peer_string(), process_queue(), process_queue(), progress_cb(), progress_cb(), progress_cb(), progress_cb(), put_cb(), read_stdio(), read_task(), reannounce_regex(), reply_handle(), requester_callback(), responder_callback(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), service_connect_comp(), show_peer(), shutdown_if_no_lifeness(), shutdown_pipe_cb(), shutdown_run(), shutdown_task(), sign_cb(), start_callback(), start_dump(), start_insert(), stats_cb(), stop_callback(), store_cb(), stun_read_task(), switch_to_speaker(), term_callback(), test_finished(), test_finished(), test_finished(), test_run(), timeout_task(), timeout_task(), timeout_task(), timeout_task(), timeout_task_cb(), trigger_shutdown(), tunnels_callback(), uri_ksk_continuation(), uri_sks_continuation(), url_resign_cb(), view_update_handle(), wait_child(), write_task(), and zone_iteration_error().

Here is the call graph for this function:

◆ GNUNET_SCHEDULER_get_load()

unsigned int GNUNET_SCHEDULER_get_load ( enum GNUNET_SCHEDULER_Priority  p)

Get information about the current load of this scheduler.

Use this function to determine if an elective task should be added or simply dropped (if the decision should be made based on the number of tasks ready to run).

Parameters
ppriority-level to query, use KEEP to query the level of the current task, use COUNT to get the sum over all priority levels
Returns
number of tasks pending right now

Use this function to determine if an elective task should be added or simply dropped (if the decision should be made based on the number of tasks ready to run).

Parameters
ppriority level to look at
Returns
number of tasks pending right now

Definition at line 781 of file scheduler.c.

782{
783 unsigned int ret;
784
785 GNUNET_assert (NULL != active_task);
787 return ready_count;
790 ret = 0;
791 for (struct GNUNET_SCHEDULER_Task *pos = ready_head[check_priority (p)];
792 NULL != pos;
793 pos = pos->next)
794 ret++;
796 // Don't count the dummy marker
797 ret--;
798 return ret;
799}
static int ret
Final status code.
Definition gnunet-arm.c:93
static struct GNUNET_OS_Process * p
Helper process we started.
Definition gnunet-uri.c:38
static enum GNUNET_SCHEDULER_Priority check_priority(enum GNUNET_SCHEDULER_Priority p)
Check that the given priority is legal (and return it).
Definition scheduler.c:467

References active_task, check_priority(), current_priority, GNUNET_assert, GNUNET_SCHEDULER_PRIORITY_COUNT, GNUNET_SCHEDULER_PRIORITY_KEEP, GNUNET_SCHEDULER_Task::in_ready_list, GNUNET_SCHEDULER_Task::next, p, pass_end_marker, GNUNET_SCHEDULER_Task::priority, ready_count, ready_head, and ret.

Here is the call graph for this function:

◆ GNUNET_SCHEDULER_get_task_context()

const struct GNUNET_SCHEDULER_TaskContext * GNUNET_SCHEDULER_get_task_context ( void  )

Obtain the reasoning why the current task was started.

Returns
task context with information why the current task is run

Obtain the reasoning why the current task was started.

Returns
current tasks' scheduler context

Definition at line 764 of file scheduler.c.

765{
766 GNUNET_assert (NULL != active_task);
767 return &tc;
768}

References active_task, GNUNET_assert, and tc.

Referenced by cmd_read(), connect_probe_continuation(), do_read(), do_read(), do_s5r_read(), do_udp_read(), do_udp_read(), do_udp_read(), maint_child_death(), read_dns4(), read_dns6(), read_response(), and tcp_send().

Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_cancel()

void * GNUNET_SCHEDULER_cancel ( struct GNUNET_SCHEDULER_Task task)

Cancel the task with the specified identifier.

The task must not yet have run. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
taskid of the task to cancel
Returns
original closure of the task

Definition at line 986 of file scheduler.c.

987{
989 int is_fd_task;
990 void *ret;
991
993 "canceling task %p\n",
994 task);
995
996 /* scheduler must be running */
998 is_fd_task = (NULL != task->fds);
999 if (is_fd_task)
1000 {
1001 int del_result = scheduler_driver->del (scheduler_driver->cls, task);
1002 if (GNUNET_OK != del_result)
1003 {
1005 "driver could not delete task\n");
1006 GNUNET_assert (0);
1007 }
1008 }
1009 if (! task->in_ready_list)
1010 {
1011 if (is_fd_task)
1012 {
1015 task);
1016 }
1017 else if (GNUNET_YES == task->on_shutdown)
1018 {
1021 task);
1022 }
1023 else
1024 {
1027 task);
1028 if (pending_timeout_last == task)
1029 pending_timeout_last = NULL;
1030 }
1031 }
1032 else
1033 {
1034 p = check_priority (task->priority);
1036 ready_tail[p],
1037 task);
1038 ready_count--;
1039 }
1040 ret = task->callback_cls;
1041 destroy_task (task);
1042 return ret;
1043}
GNUNET_SCHEDULER_Priority
Valid task priorities.
int on_shutdown
Is this task run on shutdown?
Definition scheduler.c:230

References GNUNET_SCHEDULER_Task::callback_cls, check_priority(), GNUNET_SCHEDULER_Driver::cls, GNUNET_SCHEDULER_Driver::del, destroy_task(), GNUNET_SCHEDULER_Task::fds, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_YES, GNUNET_SCHEDULER_Task::in_ready_list, LOG, GNUNET_SCHEDULER_Task::on_shutdown, p, pending_head, pending_tail, pending_timeout_head, pending_timeout_last, pending_timeout_tail, GNUNET_SCHEDULER_Task::priority, ready_count, ready_head, ready_tail, ret, scheduler_driver, shutdown_head, and shutdown_tail.

Referenced by abort_all_requests(), announce_next_regex(), backtalker_monotime_store_cb(), bi_destroy(), cadet_mq_cancel_impl(), calculate_pow_shutdown(), call_continuation(), cancel_aps(), cancel_epoch_proposal_group(), channel_destroy(), check_autoconfig_finished(), check_completed(), check_disconnect(), check_if_ack_or_heartbeat(), child_management_done(), clean_request(), cleaning_task(), cleaning_task(), cleanup(), cleanup(), cleanup_cth(), cleanup_finish(), cleanup_handle(), cleanup_handle(), cleanup_handle(), cleanup_handle(), cleanup_handle(), cleanup_handle(), cleanup_rs(), cleanup_s5r(), cleanup_task(), cleanup_task(), clear_message_store(), client_disconnect_cb(), client_disconnect_cb(), client_disconnect_cb(), client_disconnect_cb(), client_disconnect_cb(), client_disconnect_cb(), client_disconnect_cb(), close_srv_handle_room(), connection_client_cancel_impl(), connection_client_destroy_impl(), connection_destroy(), connection_ready_cb(), connection_update_timer(), consider_peer_activate(), consider_peer_destroy(), consider_sending_fc(), consume_ticket(), continuation_print(), continue_store_activity(), create_address_entry(), cummulative_ack(), curl_download_prepare(), curl_task_download(), data_sent_cb(), destroy_channel(), destroy_channel(), destroy_epoch(), destroy_epoch_announcement(), destroy_handle(), destroy_iterator_cb(), destroy_message_control(), destroy_operation(), destroy_peer(), destroy_room(), destroy_service(), destroy_srv_handle(), destroy_srv_room(), destroy_sub(), destroy_subscription(), destroy_tunnel(), DHTU_ip_done(), disconnect_cb(), disconnect_cb(), disconnect_notify(), dns_result_parser(), dns_result_processor(), do_cleanup(), do_close_listening_socket(), do_error(), do_s5r_read(), do_scheduler_notify(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown_later(), do_stop_task(), do_stop_task(), do_suspend(), done_finish(), exp_cb(), finish_test(), free_ack_cummulator_cb(), free_active_lookup(), free_address_list_entry(), free_backtalker(), free_dv_route(), free_neighbour(), free_peer(), free_pending_request(), free_proto_queue(), free_proto_queue(), free_qe(), free_queue(), free_queue_entry(), free_validation_state(), free_virtual_link(), GCC_destroy(), GCC_handle_connection_create_ack(), GCC_handle_duplicate_create(), GCC_transmit(), GCCH_bind(), GCCH_channel_local_destroy(), GCCH_handle_channel_open_ack(), GCCH_handle_channel_plaintext_data_ack(), GCCH_handle_local_data(), GCD_hello_update(), GCD_shutdown(), GCO_shutdown(), GCP_add_connection(), GCT_add_channel(), GCT_change_estate(), GCT_destroy_tunnel_now(), GCT_handle_encrypted(), GCT_handle_kx(), GCT_send(), GDS_CLIENTS_stop(), GDS_u_disconnect(), get_cadet(), get_iter(), get_lt_delete_it(), get_lt_delete_it(), get_request_socket(), GN_nat_status_changed(), GN_stop_gnunet_nat_server_(), GNS_resolver_lookup_cancel(), GNUNET_ABD_disconnect(), GNUNET_ARM_disconnect(), GNUNET_ARM_monitor_stop(), GNUNET_ARM_operation_cancel(), GNUNET_BANDWIDTH_tracker_notification_stop(), GNUNET_CADET_disconnect(), GNUNET_CADET_get_channel_cancel(), GNUNET_CADET_get_path_cancel(), GNUNET_CADET_list_peers_cancel(), GNUNET_CADET_list_tunnels_cancel(), GNUNET_CORE_disconnect(), GNUNET_CORE_UNDERLAY_DUMMY_disconnect(), GNUNET_CRYPTO_hash_file_cancel(), GNUNET_CURL_gnunet_rc_destroy(), GNUNET_CURL_gnunet_scheduler_reschedule(), GNUNET_DATASTORE_disconnect(), GNUNET_DHT_disconnect(), GNUNET_DNS_disconnect(), GNUNET_DNSSTUB_resolve_cancel(), GNUNET_FS_dequeue_(), GNUNET_FS_directory_scan_abort(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_stop(), GNUNET_FS_publish_ksk_cancel(), GNUNET_FS_publish_signal_suspend_(), GNUNET_FS_publish_stop(), GNUNET_FS_publish_ublock_cancel_(), GNUNET_FS_queue_(), GNUNET_FS_search_pause(), GNUNET_FS_search_probe_progress_(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_start_searching_(), GNUNET_FS_search_stop(), GNUNET_FS_search_stop_probe_(), GNUNET_FS_stop(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_GNS_disconnect(), GNUNET_HELPER_destroy(), GNUNET_HELPER_kill(), GNUNET_HELPER_send_cancel(), GNUNET_HELPER_wait(), GNUNET_HOSTLIST_client_stop(), GNUNET_HOSTLIST_server_stop(), GNUNET_IDENTITY_disconnect(), GNUNET_MQ_destroy(), GNUNET_NAMECACHE_disconnect(), GNUNET_NAMESTORE_disconnect(), GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_AUTO_test_stop(), GNUNET_NAT_autoconfig_cancel(), GNUNET_NAT_mini_get_external_ipv4_cancel_(), GNUNET_NAT_mini_map_stop(), GNUNET_NAT_test_start(), GNUNET_NAT_test_stop(), GNUNET_NAT_unregister(), GNUNET_NSE_disconnect(), GNUNET_NT_scanner_done(), GNUNET_OS_command_stop(), GNUNET_PILS_disconnect(), GNUNET_PQ_disconnect(), GNUNET_PQ_event_listen_cancel(), GNUNET_RECLAIM_disconnect(), GNUNET_RESOLVER_disconnect(), GNUNET_RESOLVER_hostname_get(), GNUNET_RESOLVER_ip_get(), GNUNET_RESOLVER_request_cancel(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_disable_continue_warning(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_stop(), GNUNET_SET_listen_cancel(), GNUNET_SETI_listen_cancel(), GNUNET_SETU_listen_cancel(), GNUNET_SPEEDUP_stop_(), GNUNET_STATISTICS_destroy(), GNUNET_stop_burst(), GNUNET_TESTING_interpreter_fail(), GNUNET_TRANSPORT_application_done(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), GNUNET_TRANSPORT_TESTING_stop_peer(), GNUNET_VPN_disconnect(), GSC_KX_done(), GSC_SESSIONS_end(), GSF_cadet_release_clients(), GSF_connected_peer_done_(), GSF_peer_disconnect_handler(), GSF_pending_request_cancel_(), GSF_plan_notify_peer_disconnect_(), GSF_push_done_(), GSF_put_done_(), handle_add_address(), handle_announce(), handle_core_disconnect(), handle_core_disconnect(), handle_del_address(), handle_dht_local_get(), handle_disconnect_confirm(), handle_discourse_subscription(), handle_dns_response(), handle_external_ip(), handle_flow_control(), handle_heartbeat(), handle_helper_local_finished(), handle_incoming_msg(), handle_incoming_msg(), handle_incoming_msg(), handle_initiator_done(), handle_monitor_next(), handle_p2p_estimate(), handle_plaintext_channel_open(), handle_responder_hello(), handle_stream_input(), handle_stun(), handle_transport_notify_disconnect(), identity_changed(), incoming_destroy(), incoming_destroy(), incoming_destroy(), insert_sorted(), iterate_destroy_action(), iterate_destroy_subscription(), kill_httpd(), kill_httpd(), maint_child_death(), manage_first_hop_mq(), mhd_log_callback(), monitor_unblock(), mq_cancel(), mq_cancel_impl(), mq_error_handler(), mq_error_handler(), mq_send_d(), netjail_exec_cleanup(), notify_connect(), notify_connect(), numeric_reverse(), on_identity(), parent_control_handler(), parse(), pending_reversals_delete_it(), pending_reversals_delete_it(), primary_task(), process_job_queue(), process_local_reply(), process_peer_iteration_cb(), process_peer_monitoring_cb(), process_peer_string(), process_queue(), process_queue(), process_stat_done(), queue_burst(), queue_destroy(), queue_destroy(), queue_destroy(), reconnect_later(), reconstruct_cont(), refresh_timeout_task(), regex_found_handler(), remove_channel_ctx(), remove_stream_request(), reschedule_hellos(), reset_cadet_async(), reset_handles(), RPS_sampler_request_cancel(), RPS_sampler_request_single_info_cancel(), run(), run_mhd_now(), run_mhd_now(), schedule_current_round(), schedule_httpd(), schedule_httpd(), schedule_read(), schedule_transmit_on_queue(), scheduler_fd_cb(), search_result_freeze_probes(), secret_destroy(), select_read_cb(), send_response(), service_mq_cancel(), set_epoch_announcement_appeal(), shutdown_hook(), shutdown_pch(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), start_closing_period(), start_draining_period(), start_process(), stop_helper(), stop_operation(), stop_peer_run(), stop_stun(), stream_start_response(), switch_to_speaker(), teardown_service(), terminate_ac_activities(), terminate_task(), test_master(), test_nat_punched(), timeout_task_cb(), try_transmission(), update_backtalker_monotime(), update_epoch_group(), update_excess(), update_flood_times(), update_next_challenge_time(), update_subscription_timing(), update_timeout(), validation_transmit_on_queue(), and zone_iteration_error().

Here is the call graph for this function:

◆ GNUNET_SCHEDULER_add_with_reason_and_priority()

void GNUNET_SCHEDULER_add_with_reason_and_priority ( GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls,
enum GNUNET_SCHEDULER_Reason  reason,
enum GNUNET_SCHEDULER_Priority  priority 
)

Continue the current execution with the given function.

This is similar to the other "add" functions except that there is no delay and the reason code can be specified.

Parameters
taskmain function of the task
task_clsclosure for task
reasonreason for task invocation
prioritypriority to use for the task

Definition at line 1080 of file scheduler.c.

1087{
1088 struct GNUNET_SCHEDULER_Task *t;
1089
1090 /* scheduler must be running */
1092 GNUNET_assert (NULL != task);
1094 t->read_fd = -1;
1095 t->write_fd = -1;
1096 t->callback = task;
1097 t->callback_cls = task_cls;
1098#if PROFILE_DELAYS
1099 t->start_time = GNUNET_TIME_absolute_get ();
1100#endif
1101 t->reason = reason;
1105 "Adding continuation task %p\n",
1106 t);
1107 init_backtrace (t);
1109}
static struct GNUNET_SCHEDULER_Task * t
Main task.
static void init_backtrace(struct GNUNET_SCHEDULER_Task *t)
Initialize backtrace data for task t.
Definition scheduler.c:1052
int write_fd
Set if we only wait for writing to a single FD, otherwise -1.
Definition scheduler.c:219
int read_fd
Set if we only wait for reading from a single FD, otherwise -1.
Definition scheduler.c:214

References GNUNET_SCHEDULER_Task::callback, GNUNET_SCHEDULER_Task::callback_cls, check_priority(), current_lifeness, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_TIME_absolute_get(), init_backtrace(), GNUNET_SCHEDULER_Task::lifeness, LOG, GNUNET_SCHEDULER_Task::priority, queue_ready_task(), GNUNET_SCHEDULER_Task::read_fd, GNUNET_SCHEDULER_Task::reason, scheduler_driver, t, and GNUNET_SCHEDULER_Task::write_fd.

Referenced by GNUNET_SCHEDULER_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_with_priority()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority ( enum GNUNET_SCHEDULER_Priority  prio,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified priority.

Parameters
priohow important is the new task?
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1237 of file scheduler.c.

1240{
1242 prio,
1243 task,
1244 task_cls);
1245}
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1213
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.

References GNUNET_SCHEDULER_add_delayed_with_priority(), and GNUNET_TIME_UNIT_ZERO.

Referenced by begin_service(), block_proc(), create_srv_room(), dequeue_message_from_room(), dequeue_messages_from_room(), deserialize_publish_file(), do_shutdown(), ds_put_cont(), encode_cont(), file_hash_task(), finish_reserve(), GNUNET_CRYPTO_hash_file(), GNUNET_FS_publish_start(), GNUNET_SCHEDULER_driver_init(), GSF_connected_peer_init_(), iterate_message_control(), maint_child_death(), on_message(), publish_kblocks_cont(), put_store_message(), require_message_from_room(), run(), run(), run(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_now()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now ( GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run as soon as possible.

Note that this does not guarantee that this will be the next task that is being run, as other tasks with higher priority (or that are already ready to run) might get to run first. Just as with delays, clients must not rely on any particular order of execution between tasks scheduled concurrently.

The task will be run with the DEFAULT priority.

Parameters
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1310 of file scheduler.c.

1312{
1313 struct GNUNET_SCHEDULER_Task *t;
1314
1317 t->callback = task;
1318 t->callback_cls = task_cls;
1319 t->read_fd = -1;
1320 t->write_fd = -1;
1321#if PROFILE_DELAYS
1322 t->start_time = GNUNET_TIME_absolute_get ();
1323#endif
1329 init_backtrace (t);
1330 return t;
1331}
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.

References GNUNET_SCHEDULER_Task::callback, GNUNET_SCHEDULER_Task::callback_cls, current_lifeness, current_priority, GNUNET_async_scope_get(), GNUNET_new, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, init_backtrace(), GNUNET_SCHEDULER_Task::lifeness, GNUNET_SCHEDULER_Task::on_shutdown, GNUNET_SCHEDULER_Task::priority, queue_ready_task(), GNUNET_SCHEDULER_Task::read_fd, GNUNET_SCHEDULER_Task::scope, t, GNUNET_SCHEDULER_Task::timeout, and GNUNET_SCHEDULER_Task::write_fd.

Referenced by add_attribute_cont(), add_continuation(), add_credential_cont(), advertise_dns_exit(), announce_regex(), attr_delete_cont(), attr_store_cont(), authorize_endpoint(), backchannel_check_run(), build_authz_response(), build_redirect(), bulk_tx_start(), cadet_mq_send_impl(), check_autoconfig_finished(), check_for_messages(), client_response_handler(), code_redirect(), collect_error_cb(), collect_finished_cb(), connect_cb(), connection_client_send_impl(), connection_update_timer(), consistency_iter_fin(), consume_cont(), consume_fail(), consume_ticket_cont(), continuation_print(), continue_with_gns2dns(), cr_cont(), create_address_entry(), create_did(), create_did_cb(), create_did_ego_create_cb(), create_did_ego_lockup_cb(), create_download_context(), create_finished(), create_receiver(), cred_delete_cont(), cred_error(), cred_iter_finished(), cred_store_cont(), decrypt_box(), del_attr_finished(), del_finished(), delete_attribute_cont(), delete_credential_cont(), delete_finished_cb(), deserialize_download(), DHTU_ip_init(), disconnect_notify(), dns_result_parser(), do_abort(), do_announce(), do_error(), do_finished(), do_open_listening_socket(), ego_callback(), ego_create(), ego_delete_name(), ego_delete_pubkey(), ego_edit(), ego_edit_name(), ego_edit_pubkey(), ego_get_all(), ego_get_name(), ego_get_pubkey(), ego_get_response(), ego_sign_data(), ego_sign_data_cb(), ensure_ego_and_continue(), fail_resolution(), find_timed_out(), finished_cont(), free_dv_route(), free_neighbour(), gather_dht_put_blocks(), GCCH_bind(), GCCH_channel_local_destroy(), GCCH_handle_duplicate_open(), GCCH_tunnel_up(), GCP_attach_path(), GCT_change_estate(), GCT_create_tunnel(), GCT_handle_encrypted(), GCT_handle_kx(), GCT_send(), GDS_u_connect(), get_cont(), get_gns_cont(), get_oidc_dir_path(), GN_nat_status_changed(), GNS_resolver_lookup(), GNS_resolver_lookup_cancel(), GNUNET_ARM_request_service_start(), GNUNET_CLIENT_connect(), GNUNET_CURL_gnunet_scheduler_reschedule(), GNUNET_DNS_connect(), GNUNET_DNSSTUB_resolve(), GNUNET_FS_dequeue_(), GNUNET_FS_download_start_task_(), GNUNET_FS_publish_ksk(), GNUNET_FS_publish_ublock_(), GNUNET_FS_queue_(), GNUNET_FS_search_probe_progress_(), GNUNET_HOSTLIST_client_start(), GNUNET_MQ_impl_send_continue(), GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_NAT_test_start(), GNUNET_PQ_event_notify(), GNUNET_RESOLVER_hostname_get(), GNUNET_RESOLVER_ip_get(), GNUNET_SCHEDULER_add_now_with_lifeness(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TESTING_interpreter_fail(), GNUNET_TESTING_interpreter_next_(), GNUNET_TRANSPORT_TESTING_start_peer(), GSF_plan_add_(), GSF_put_init_(), handle_add_queue_message(), handle_attribute_store_message(), handle_credential_store_message(), handle_dht_local_get(), handle_disconnect_confirm(), handle_gns_redirect_result(), handle_gns_resolution_result(), handle_gns_response(), handle_local_ack(), handle_monitor_next(), handle_monitor_next(), handle_monitor_start(), handle_monitor_start(), handle_p2p_estimate(), handle_p2p_reply(), handle_stop(), handle_stream_input(), handler_advertisement(), hello_iter_cb(), hello_iter_cb(), identity_cb(), identity_cb(), idle(), iface_proc(), import_next_cb(), init_callback(), iter_error(), iter_finished(), kb_put_cont(), launch_daemons(), launch_registered_services(), list_attribute_cont(), list_callback(), list_credential_cont(), list_tickets_cont(), login_redirect(), lookup_hole_external(), lookup_redirect_uri_result(), main_task(), marked_deleted(), message_sent_cont(), monitor_iterate_cb(), monitor_iterate_cb(), namestore_add_or_update(), namestore_delete(), namestore_get(), namestore_import(), namestore_iteration_error(), namestore_list_finished(), new_sub(), notification_pipe_cb(), notify_srv_handle_member_id(), ns_get_lookup_cb(), ns_lookup_cb(), ns_lookup_error_cb(), offending_attr_delete_cont(), oidc_attr_collect_finished_cb(), oidc_iteration_error(), oidc_ticket_issue_cb(), options_cont(), options_cont(), options_cont(), origin_create_cb(), parse(), pid_change_cb(), post_ego_iteration(), primary_task(), print_did_document(), process_attrs(), process_delete(), process_dht_put_content(), process_dids(), process_helper_msgs(), process_result(), process_rvk(), process_stdin(), progress_cb(), progress_cb(), progress_cb(), progress_cb(), purge_attributes(), put_cont(), queue_read_kx(), queue_read_kx(), read_stdio(), reconnect_later(), reconstruct_cb(), recursive_dns_resolution(), recursive_gns2dns_resolution(), recursive_pkey_resolution(), regex_found_handler(), remove_did_document(), remove_did_document_namestore_cb(), replace_cont(), replace_did_document(), reschedule_hellos(), reset_cadet_async(), resolve_did(), revoke_ticket_cont(), RPS_sampler_get_n_rand_peers(), RPS_sampler_get_rand_peer_info(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run_mhd_now(), run_mhd_now(), rvk_move_attr_cb(), rvk_ticket_update_finished(), schedule_channel_destruction(), schedule_next_task(), search_timed_out(), send_simple_single(), service_mq_send(), set_cont(), setup_is(), setup_sender(), sock_read(), start_callback(), start_peer_run(), start_probe_ping_task(), start_process(), start_resolver_lookup(), stat_timeout_task(), stop_callback(), store_completed_cb(), store_cont(), task_check(), term_callback(), test_icmp_server(), test_master(), ticket_issue_cb(), ticket_iter_err(), ticket_iter_fin(), ticket_processed(), ticket_updated(), timeout_task(), token_endpoint(), try_connect(), try_notify_connect(), userinfo_endpoint(), zone_iteration_error(), zone_iteration_finished(), and zone_iteration_finished().

Here is the call graph for this function:

◆ GNUNET_SCHEDULER_add_shutdown()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown ( GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.

Parameters
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1345 of file scheduler.c.

1347{
1348 struct GNUNET_SCHEDULER_Task *t;
1349
1350 /* scheduler must be running */
1352 GNUNET_assert (NULL != task);
1355 t->callback = task;
1356 t->callback_cls = task_cls;
1357 t->read_fd = -1;
1358 t->write_fd = -1;
1359#if PROFILE_DELAYS
1360 t->start_time = GNUNET_TIME_absolute_get ();
1361#endif
1365 t->lifeness = GNUNET_NO;
1368 t);
1370 "Adding shutdown task %p\n",
1371 t);
1372 init_backtrace (t);
1373 return t;
1374}
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".

References GNUNET_SCHEDULER_Task::callback, GNUNET_SCHEDULER_Task::callback_cls, GNUNET_assert, GNUNET_async_scope_get(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_SHUTDOWN, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, init_backtrace(), GNUNET_SCHEDULER_Task::lifeness, LOG, GNUNET_SCHEDULER_Task::on_shutdown, GNUNET_SCHEDULER_Task::priority, GNUNET_SCHEDULER_Task::read_fd, scheduler_driver, GNUNET_SCHEDULER_Task::scope, shutdown_head, shutdown_tail, t, GNUNET_SCHEDULER_Task::timeout, and GNUNET_SCHEDULER_Task::write_fd.

Referenced by connect_check_run(), create_service(), ego_callback(), GNUNET_OS_install_parent_control_handler(), init_cb(), launch_registered_services(), loop_run(), main_init(), main_task(), on_identity(), program_main(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), service_main(), test_master(), and test_master().

Here is the call graph for this function:

◆ GNUNET_SCHEDULER_add_now_with_lifeness()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now_with_lifeness ( int  lifeness,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run as soon as possible with the (transitive) ignore-shutdown flag either explicitly set or explicitly enabled.

This task (and all tasks created from it, other than by another call to this function) will either count or not count for the 'lifeness' of the process. This API is only useful in a few special cases.

Parameters
lifenessGNUNET_YES if the task counts for lifeness, GNUNET_NO if not.
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1378 of file scheduler.c.

1381{
1382 struct GNUNET_SCHEDULER_Task *ret;
1383
1384 ret = GNUNET_SCHEDULER_add_now (task, task_cls);
1385 ret->lifeness = lifeness;
1386 return ret;
1387}
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition scheduler.c:1310

References GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_Task::lifeness, and ret.

Referenced by GNUNET_SPEEDUP_start_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_delayed()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed ( struct GNUNET_TIME_Relative  delay,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay.

The task will be scheduled for execution once the delay has expired. It will be run with the DEFAULT priority.

Parameters
delaywith which the operation should be run
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

The task will be scheduled for execution once the delay has expired. It will be run with the DEFAULT priority.

Parameters
delaywhen should this operation time out?
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1283 of file scheduler.c.

1286{
1289 task,
1290 task_cls);
1291}

References GNUNET_SCHEDULER_add_delayed_with_priority(), and GNUNET_SCHEDULER_PRIORITY_DEFAULT.

Referenced by age_cover_counters(), announce_id(), announce_next_regex(), calculate_pow(), callback_mq_error(), channel_new_cb(), channel_new_cb(), channel_new_cb(), channel_open_sent_cb(), check_disconnect(), check_timeouts(), check_zone_namestore_next(), cleanup_expired_records(), client_connect_cb(), connect_check_run(), connect_fail_continuation(), connection_ready_cb(), connection_update_timer(), consider_gathering(), consider_peer_destroy(), consider_sending_fc(), continue_store_activity(), core_init(), curl_download_prepare(), daemon_started(), delay_warning(), delayed_get(), dht_connected(), disconnect_and_schedule_reconnect(), disconnect_and_schedule_reconnect(), dns_pre_request_handler(), do_broadcast(), do_dht_put(), do_disconnect(), do_disconnect(), do_discover_peers(), do_open_listening_socket(), do_refresh(), do_round(), do_scheduler_notify(), do_speedup(), error_handler(), error_handler(), error_handler(), error_handler(), expire_records_continuation(), find_string(), force_reconnect(), force_reconnect(), force_reconnect(), force_reconnect(), force_reconnect(), force_reconnect(), force_reconnect(), GCC_handle_connection_create_ack(), GCCH_channel_incoming_new(), GCD_hello_update(), GCD_init(), GCT_remove_channel(), get_addresses(), get_cadet(), GNUNET_FS_search_probe_progress_(), GNUNET_get_udp_socket(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_server_start(), GNUNET_NAMESTORE_records_store(), GNUNET_NAT_mini_map_start(), GNUNET_NAT_test_start(), GNUNET_NT_scanner_init(), GNUNET_PQ_event_listen(), GNUNET_RESOLVER_hostname_get(), GNUNET_RESOLVER_ip_get(), GNUNET_STATISTICS_destroy(), GNUNET_TESTING_run(), GSF_cadet_query_cancel(), handle_add_address(), handle_announce(), handle_autoconfig_request(), handle_client_listener_error(), handle_client_listener_error(), handle_client_listener_error(), handle_connection_create(), handle_core_connect(), handle_core_connect(), handle_data(), handle_del_address(), handle_external_ip(), handle_fragment_box(), handle_heartbeat(), handle_monitor_next(), handle_mq_error(), handle_msg_test(), handle_p2p_migration_stop(), handle_p2p_reply(), handle_request(), handle_responder_hello_cont(), handle_stun(), handler_advertisement(), helper_read(), helper_write(), ifc_broadcast(), iter_finished(), kce_generate_cb(), keepalive_done(), learn_dv_path(), lookup_authz_cb(), main_init(), maintain_connections_cb(), manage_first_hop_mq(), monitor_unblock(), mq_error_handler(), mq_error_handler(), mq_init(), mq_init(), netjail_exec_run(), odc_warn_delay_task(), peerstore_store_own_cb(), probe_ping_task_cb(), process_external_ip(), process_job_queue(), process_local_reply(), process_map_output(), process_peer_iteration_cb(), process_peer_monitoring_cb(), process_queue(), process_queue(), process_queue(), process_queue(), process_queue(), process_requests(), queue_burst(), queue_send_msg(), queue_timeout(), read_from_log(), read_send(), reannounce(), reannounce_regex(), reconnect(), reconnect(), reconnect(), reconnect(), reconnect(), reconnect_arm_later(), reconnect_arm_monitor_later(), reconnect_later(), reconnect_later(), recursive_dns_resolution(), refresh_timeout_task(), reschedule_connect(), resend_initiator_done(), resend_initiator_hello(), resend_responder_hello(), resolve_and_cache(), REST_gns_process_request(), rest_identity_process_request(), REST_identity_process_request(), REST_namestore_process_request(), REST_openid_process_request(), REST_reclaim_process_request(), revive_migration(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run_external_ip(), run_finish(), run_scan(), scan(), schedule_current_round(), schedule_httpd(), schedule_next_hello(), schedule_next_put(), schedule_next_task(), send_create_ack(), send_find_peer_message(), send_heartbeat(), send_initiator_hello(), send_keepalive(), send_responder_hello(), service_client_mst_cb(), setup_data_transfer(), setup_queue(), shc_cont(), sign_dv_init_cb(), start_burst(), start_cb(), start_closing_period(), start_draining_period(), start_dv_learn(), start_helper(), start_local_query(), store_pi(), stream_start_response(), switch_to_speaker(), task_check(), task_download_dispatcher(), task_hostlist_saving(), test_master(), test_master(), transmit_cummulative_ack_cb(), transmit_query(), transmit_task_cb(), try_again(), try_reconnect(), try_reconnect(), try_reconnect(), update_excess(), update_flood_message(), update_flood_times(), update_subscription_timing(), update_timeout(), userinfo_endpoint(), warn_delay_task(), warn_monitor_slow(), warn_no_client_continue(), work(), and zone_iteration_finished().

Here is the call graph for this function:

◆ GNUNET_SCHEDULER_add_at()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at ( struct GNUNET_TIME_Absolute  at,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run at the specified time.

The task will be scheduled for execution once specified time has been reached. It will be run with the DEFAULT priority.

Parameters
attime at which this operation should run
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1260 of file scheduler.c.

1263{
1266 task,
1267 task_cls);
1268}
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at_with_priority(struct GNUNET_TIME_Absolute at, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition scheduler.c:1124

References GNUNET_SCHEDULER_add_at_with_priority(), and GNUNET_SCHEDULER_PRIORITY_DEFAULT.

Referenced by activate_core_visible_dv_path(), backtalker_monotime_store_cb(), backtalker_timeout_cb(), check_link_down(), connection_ready_cb(), cummulative_ack(), data_sent_cb(), decaps_dv_box_cb(), GCC_handle_duplicate_create(), GCCH_handle_channel_plaintext_data_ack(), GCT_add_channel(), GCT_handle_kx_auth(), handle_validation_response(), identity_changed(), insert_sorted(), manage_first_hop_mq(), path_cleanup_cb(), process_queue(), process_queue(), reassembly_cleanup_task(), schedule_peer_transmission(), timeout_cb(), transmit_next_request_task(), try_transmission(), update_flood_message(), and update_next_challenge_time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_delayed_with_priority()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority ( struct GNUNET_TIME_Relative  delay,
enum GNUNET_SCHEDULER_Priority  priority,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay.

The task will be scheduled for execution once the delay has expired.

Parameters
delaywhen should this operation time out?
prioritypriority to use for the task
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1213 of file scheduler.c.

1218{
1221 priority,
1222 task,
1223 task_cls);
1224}
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition time.c:316

References GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_TIME_relative_to_absolute(), and GNUNET_SCHEDULER_Task::priority.

Referenced by cron_flush_respect(), delay_room_action(), delayed_disconnect_channel(), delayed_restart_task(), expired_processor(), find_proof(), find_proof(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_with_priority(), handle_discourse_subscription(), handle_room_request_task(), idle_request_room_messages(), load_operation(), schedule_transmit_on_queue(), set_epoch_proposal_group(), and start_operation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_at_with_priority()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at_with_priority ( struct GNUNET_TIME_Absolute  at,
enum GNUNET_SCHEDULER_Priority  priority,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run at the specified time.

The task will be scheduled for execution at time at.

Parameters
attime when the operation should run
prioritypriority to use for the task
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1124 of file scheduler.c.

1128{
1129 struct GNUNET_SCHEDULER_Task *t;
1130 struct GNUNET_SCHEDULER_Task *pos;
1132 struct GNUNET_TIME_Relative left;
1133
1134 /* scheduler must be running */
1136 GNUNET_assert (NULL != task);
1139 t->callback = task;
1140 t->callback_cls = task_cls;
1141 t->read_fd = -1;
1142 t->write_fd = -1;
1143#if PROFILE_DELAYS
1144 t->start_time = GNUNET_TIME_absolute_get ();
1145#endif
1146 t->timeout = at;
1147 t->priority = check_priority (priority);
1149 init_backtrace (t);
1150
1152 if (0 == left.rel_value_us)
1153 {
1155 if (priority > work_priority)
1156 work_priority = priority;
1157 return t;
1158 }
1159
1160 /* try tail first (optimization in case we are
1161 * appending to a long list of tasks with timeouts) */
1162 if ((NULL == pending_timeout_head) ||
1164 {
1167 t);
1168 }
1169 else
1170 {
1171 /* first move from heuristic start backwards to before start time */
1172 prev = pending_timeout_last;
1173 while ((NULL != prev) &&
1175 prev = prev->prev;
1176 /* now, move from heuristic start (or head of list) forward to insertion point */
1177 if (NULL == prev)
1179 else
1180 pos = prev->next;
1181 while ((NULL != pos) && (pos->timeout.abs_value_us <=
1183 {
1184 prev = pos;
1185 pos = pos->next;
1186 }
1189 prev,
1190 t);
1191 }
1192 /* finally, update heuristic insertion point to last insertion... */
1195 "Adding task %p\n",
1196 t);
1197 return t;
1198}
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition time.c:406
struct GNUNET_SCHEDULER_Task * prev
This is a linked list.
Definition scheduler.c:150
Time for relative time used by GNUnet, in microseconds.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_SCHEDULER_Task::callback, GNUNET_SCHEDULER_Task::callback_cls, check_priority(), current_lifeness, GNUNET_assert, GNUNET_async_scope_get(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_insert_after, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), init_backtrace(), GNUNET_SCHEDULER_Task::lifeness, LOG, GNUNET_SCHEDULER_Task::next, pending_timeout_head, pending_timeout_last, pending_timeout_tail, GNUNET_SCHEDULER_Task::prev, GNUNET_SCHEDULER_Task::priority, queue_ready_task(), GNUNET_SCHEDULER_Task::read_fd, GNUNET_TIME_Relative::rel_value_us, scheduler_driver, GNUNET_SCHEDULER_Task::scope, t, GNUNET_SCHEDULER_Task::timeout, work_priority, and GNUNET_SCHEDULER_Task::write_fd.

Referenced by GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_delayed_with_priority(), and set_epoch_announcement_appeal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_read_net()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net ( struct GNUNET_TIME_Relative  delay,
struct GNUNET_NETWORK_Handle rfd,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for reading.

The delay can be used as a timeout on the socket being ready. The task will be scheduled for execution once either the delay has expired or the socket operation is ready. It will be run with the DEFAULT priority. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
delaywhen should this operation time out?
rfdread file-descriptor
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1517 of file scheduler.c.

1521{
1524 rfd, task, task_cls);
1525}
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority and to be run after the specified delay or wh...
Definition scheduler.c:1551

References GNUNET_SCHEDULER_add_read_net_with_priority(), and GNUNET_SCHEDULER_PRIORITY_DEFAULT.

Referenced by accept_client(), check_for_messages(), connect_success_continuation(), core_read_finished_cb(), core_read_finished_cb(), create_listen_socket(), create_proto_queue(), create_proto_queue(), create_receiver(), delayed_restart_task(), DHTU_ip_init(), do_accept(), do_accept(), do_accept(), do_accept(), do_accept(), do_connect_to_peer(), do_open_listening_socket(), do_read(), do_resume(), do_s5r_read(), do_scheduler_notify(), do_udp_read(), do_udp_read(), GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_test_start(), init_socket(), init_socket(), listen_cb(), listen_cb(), maint_child_death(), mq_init(), mq_init(), proto_read_kx(), proto_read_kx(), queue_destroy(), queue_destroy(), queue_read(), queue_read(), queue_read_kx(), queue_read_kx(), read_cb(), read_dns4(), read_dns6(), read_send(), receive_complete_cb(), receive_ready(), resume_client_receive(), run(), run(), run(), run(), run(), run(), run(), run(), scheduler_fd_cb(), select_read_cb(), service_client_recv(), sock_read(), sock_read(), sock_read(), start_client(), stun_read_task(), test_nat_punched(), and test_stun().

Here is the call graph for this function:

◆ GNUNET_SCHEDULER_add_read_net_with_priority()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net_with_priority ( struct GNUNET_TIME_Relative  delay,
enum GNUNET_SCHEDULER_Priority  priority,
struct GNUNET_NETWORK_Handle rfd,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified priority and to be run after the specified delay or when the specified file descriptor is ready for reading.

The delay can be used as a timeout on the socket being ready. The task will be scheduled for execution once either the delay has expired or the socket operation is ready. It will be run with the DEFAULT priority. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
delaywhen should this operation time out?
prioritypriority to use for the task
rfdread file-descriptor
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1551 of file scheduler.c.

1557{
1558 return GNUNET_SCHEDULER_add_net_with_priority (delay, priority,
1559 rfd,
1560 GNUNET_YES,
1561 GNUNET_NO,
1562 task, task_cls);
1563}
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_net_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, struct GNUNET_NETWORK_Handle *fd, int on_read, int on_write, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready.
Definition scheduler.c:1625

References GNUNET_NO, GNUNET_SCHEDULER_add_net_with_priority(), GNUNET_YES, and GNUNET_SCHEDULER_Task::priority.

Referenced by GNUNET_SCHEDULER_add_read_net().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_write_net()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_write_net ( struct GNUNET_TIME_Relative  delay,
struct GNUNET_NETWORK_Handle wfd,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for writing.

The delay can be used as a timeout on the socket being ready. The task will be scheduled for execution once either the delay has expired or the socket operation is ready. It will be run with the priority of the calling task. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
delaywhen should this operation time out?
wfdwrite file-descriptor
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1588 of file scheduler.c.

1592{
1595 wfd,
1597 task, task_cls);
1598}

References GNUNET_NO, GNUNET_SCHEDULER_add_net_with_priority(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, and GNUNET_YES.

Referenced by connect_success_continuation(), do_s5r_read(), do_send(), do_write(), mq_init(), mq_init(), mq_send(), mq_send(), mq_send(), mq_send_impl(), proto_queue_write(), proto_queue_write(), proto_read_kx(), proto_read_kx(), queue_read_kx(), queue_read_kx(), queue_write(), queue_write(), select_write_cb(), signal_socks_failure(), signal_socks_success(), transmit_ready(), try_connect_using_address(), try_connection_reversal(), try_handle_plaintext(), try_handle_plaintext(), try_send_tcp(), and write_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_net_with_priority()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_net_with_priority ( struct GNUNET_TIME_Relative  delay,
enum GNUNET_SCHEDULER_Priority  priority,
struct GNUNET_NETWORK_Handle fd,
int  on_read,
int  on_write,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay or when the specified file descriptor is ready.

The delay can be used as a timeout on the socket being ready. The task will be scheduled for execution once either the delay has expired or the socket operation is ready. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
delaywhen should this operation time out?
prioritypriority of the task
fdfile-descriptor
on_readwhether to poll the file-descriptor for readability
on_writewhether to poll the file-descriptor for writability
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until "task" is started!

Definition at line 1625 of file scheduler.c.

1632{
1633 /* scheduler must be running */
1635 GNUNET_assert (on_read || on_write);
1637 return add_without_sets (delay, priority,
1638 on_read ? fd : NULL,
1639 on_write ? fd : NULL,
1640 NULL,
1641 NULL,
1642 task, task_cls);
1643}
int GNUNET_NETWORK_get_fd(const struct GNUNET_NETWORK_Handle *desc)
Return file descriptor for this network handle.
Definition network.c:1001
static struct GNUNET_SCHEDULER_Task * add_without_sets(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, const struct GNUNET_NETWORK_Handle *read_nh, const struct GNUNET_NETWORK_Handle *write_nh, const struct GNUNET_DISK_FileHandle *read_fh, const struct GNUNET_DISK_FileHandle *write_fh, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when any of the specified file descriptor set...
Definition scheduler.c:1445

References add_without_sets(), GNUNET_assert, GNUNET_NETWORK_get_fd(), GNUNET_SCHEDULER_Task::priority, and scheduler_driver.

Referenced by GNUNET_SCHEDULER_add_read_net_with_priority(), and GNUNET_SCHEDULER_add_write_net().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_read_file()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file ( struct GNUNET_TIME_Relative  delay,
const struct GNUNET_DISK_FileHandle rfd,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for reading.

The delay can be used as a timeout on the socket being ready. The task will be scheduled for execution once either the delay has expired or the socket operation is ready. It will be run with the DEFAULT priority. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
delaywhen should this operation time out?
rfdread file-descriptor
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1667 of file scheduler.c.

1671{
1674 rfd, GNUNET_YES, GNUNET_NO,
1675 task, task_cls);
1676}
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_file_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, const struct GNUNET_DISK_FileHandle *fd, int on_read, int on_write, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready.
Definition scheduler.c:1736

References GNUNET_NO, GNUNET_SCHEDULER_add_file_with_priority(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, and GNUNET_YES.

Referenced by cmd_read(), GNUNET_ARM_request_service_start(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_OS_command_run(), GNUNET_OS_install_parent_control_handler(), GNUNET_SCHEDULER_driver_init(), GNUNET_wait_child(), handle_command(), helper_read(), initiate_put_from_pipe_trigger(), maint_child_death(), maint_child_death(), maint_child_death(), nat_server_read(), parent_control_handler(), read_external_ipv4(), read_task(), restart_nat_server(), run(), run(), run(), run(), shutdown_pipe_cb(), start_helper(), and work().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_write_file()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_write_file ( struct GNUNET_TIME_Relative  delay,
const struct GNUNET_DISK_FileHandle wfd,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for writing.

The delay can be used as a timeout on the socket being ready. The task will be scheduled for execution once either the delay has expired or the socket operation is ready. It will be run with the DEFAULT priority. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
delaywhen should this operation time out?
wfdwrite file-descriptor
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1700 of file scheduler.c.

1704{
1707 wfd, GNUNET_NO, GNUNET_YES,
1708 task, task_cls);
1709}

References GNUNET_NO, GNUNET_SCHEDULER_add_file_with_priority(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, and GNUNET_YES.

Referenced by GNUNET_HELPER_send(), helper_write(), write_message(), and write_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_file_with_priority()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_file_with_priority ( struct GNUNET_TIME_Relative  delay,
enum GNUNET_SCHEDULER_Priority  priority,
const struct GNUNET_DISK_FileHandle fd,
int  on_read,
int  on_write,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay or when the specified file descriptor is ready.

The delay can be used as a timeout on the socket being ready. The task will be scheduled for execution once either the delay has expired or the socket operation is ready. Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
delaywhen should this operation time out?
prioritypriority of the task
fdfile-descriptor
on_readwhether to poll the file-descriptor for readability
on_writewhether to poll the file-descriptor for writability
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

Definition at line 1736 of file scheduler.c.

1744{
1745 /* scheduler must be running */
1747 GNUNET_assert (on_read || on_write);
1748 GNUNET_assert (fd->fd >= 0);
1749 return add_without_sets (delay, priority,
1750 NULL,
1751 NULL,
1752 on_read ? fd : NULL,
1753 on_write ? fd : NULL,
1754 task, task_cls);
1755}
int fd
File handle on Unix-like systems.

References add_without_sets(), GNUNET_DISK_FileHandle::fd, GNUNET_assert, GNUNET_SCHEDULER_Task::priority, and scheduler_driver.

Referenced by GNUNET_SCHEDULER_add_read_file(), and GNUNET_SCHEDULER_add_write_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_add_select()

struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_select ( enum GNUNET_SCHEDULER_Priority  prio,
struct GNUNET_TIME_Relative  delay,
const struct GNUNET_NETWORK_FDSet rs,
const struct GNUNET_NETWORK_FDSet ws,
GNUNET_SCHEDULER_TaskCallback  task,
void *  task_cls 
)

Schedule a new task to be run with a specified delay or when any of the specified file descriptor sets is ready.

The delay can be used as a timeout on the socket(s) being ready. The task will be scheduled for execution once either the delay has expired or any of the socket operations is ready. This is the most general function of the "add" family. Note that the "prerequisite_task" must be satisfied in addition to any of the other conditions. In other words, the task will be started when (prerequisite-run) && (delay-ready || any-rs-ready || any-ws-ready) ) Only allowed to be called as long as the scheduler is running, that is one of the following conditions is met:

Parameters
priohow important is this task?
delayhow long should we wait?
rsset of file descriptors we want to read (can be NULL)
wsset of file descriptors we want to write (can be NULL)
taskmain function of the task
task_clsclosure of task
Returns
unique task identifier for the job only valid until task is started!

here we consider the case that a GNUNET_NETWORK_FDSet might be empty although its maximum FD number (nsds) is greater than 0. We handle this case gracefully because some libraries such as libmicrohttpd only provide a hint what the maximum FD number in an FD set might be and not the exact FD number (see e.g. gnunet-rest-service.c)

Definition at line 1841 of file scheduler.c.

1847{
1848 struct GNUNET_SCHEDULER_Task *t;
1849 const struct GNUNET_NETWORK_Handle **read_nhandles = NULL;
1850 const struct GNUNET_NETWORK_Handle **write_nhandles = NULL;
1851 const struct GNUNET_DISK_FileHandle **read_fhandles = NULL;
1852 const struct GNUNET_DISK_FileHandle **write_fhandles = NULL;
1853 unsigned int read_nhandles_len = 0;
1854 unsigned int write_nhandles_len = 0;
1855 unsigned int read_fhandles_len = 0;
1856 unsigned int write_fhandles_len = 0;
1857 int no_rs = (NULL == rs);
1858 int no_ws = (NULL == ws);
1859 int empty_rs = (NULL != rs) && (0 == rs->nsds);
1860 int empty_ws = (NULL != ws) && (0 == ws->nsds);
1861 int no_fds = (no_rs && no_ws) ||
1862 (empty_rs && empty_ws) ||
1863 (no_rs && empty_ws) ||
1864 (no_ws && empty_rs);
1865 int no_fds_extracted;
1866
1867 /* scheduler must be running */
1869 GNUNET_assert (NULL != task);
1870 if (! no_fds)
1871 {
1872 if (NULL != rs)
1873 {
1874 extract_handles (rs,
1875 &read_nhandles,
1876 &read_nhandles_len,
1877 &read_fhandles,
1878 &read_fhandles_len);
1879 }
1880 if (NULL != ws)
1881 {
1882 extract_handles (ws,
1883 &write_nhandles,
1884 &write_nhandles_len,
1885 &write_fhandles,
1886 &write_fhandles_len);
1887 }
1888 }
1896 no_fds_extracted = (0 == read_nhandles_len) &&
1897 (0 == read_fhandles_len) &&
1898 (0 == write_nhandles_len) &&
1899 (0 == write_fhandles_len);
1900 if (no_fds || no_fds_extracted)
1902 prio,
1903 task,
1904 task_cls);
1907 init_fd_info (t,
1908 read_nhandles,
1909 read_nhandles_len,
1910 write_nhandles,
1911 write_nhandles_len,
1912 read_fhandles,
1913 read_fhandles_len,
1914 write_fhandles,
1915 write_fhandles_len);
1916 t->callback = task;
1917 t->callback_cls = task_cls;
1919 /* free the arrays of pointers to network / file handles, the actual
1920 * handles will be freed in destroy_task */
1921 GNUNET_array_grow (read_nhandles, read_nhandles_len, 0);
1922 GNUNET_array_grow (write_nhandles, write_nhandles_len, 0);
1923 GNUNET_array_grow (read_fhandles, read_fhandles_len, 0);
1924 GNUNET_array_grow (write_fhandles, write_fhandles_len, 0);
1925#if PROFILE_DELAYS
1926 t->start_time = GNUNET_TIME_absolute_get ();
1927#endif
1929 t->priority =
1930 check_priority ((prio ==
1932 prio);
1936 t);
1939 t->priority);
1941 "Adding task %p\n",
1942 t);
1943 init_backtrace (t);
1944 return t;
1945}
#define GNUNET_MAX(a, b)
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
static void driver_add_multiple(struct GNUNET_SCHEDULER_Task *t)
calls the given function func on each FdInfo related to t.
Definition scheduler.c:920
static void init_fd_info(struct GNUNET_SCHEDULER_Task *t, const struct GNUNET_NETWORK_Handle *const *read_nh, unsigned int read_nh_len, const struct GNUNET_NETWORK_Handle *const *write_nh, unsigned int write_nh_len, const struct GNUNET_DISK_FileHandle *const *read_fh, unsigned int read_fh_len, const struct GNUNET_DISK_FileHandle *const *write_fh, unsigned int write_fh_len)
Definition scheduler.c:803
static void extract_handles(const struct GNUNET_NETWORK_FDSet *fdset, const struct GNUNET_NETWORK_Handle ***ntarget, unsigned int *extracted_nhandles, const struct GNUNET_DISK_FileHandle ***ftarget, unsigned int *extracted_fhandles)
Definition scheduler.c:1759
int nsds
Maximum number of any socket descriptor in the set (plus one)
handle to a socket
Definition network.c:53
int own_handles
Do we own the network and file handles referenced by the FdInfo structs in the fds array.
Definition scheduler.c:184

References GNUNET_SCHEDULER_Task::callback, GNUNET_SCHEDULER_Task::callback_cls, check_priority(), current_lifeness, current_priority, driver_add_multiple(), extract_handles(), GNUNET_array_grow, GNUNET_assert, GNUNET_async_scope_get(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX, GNUNET_new, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_KEEP, GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, init_backtrace(), init_fd_info(), GNUNET_SCHEDULER_Task::lifeness, LOG, max_priority_added, GNUNET_NETWORK_FDSet::nsds, GNUNET_SCHEDULER_Task::own_handles, pending_head, pending_tail, GNUNET_SCHEDULER_Task::priority, scheduler_driver, GNUNET_SCHEDULER_Task::scope, t, and GNUNET_SCHEDULER_Task::timeout.

Referenced by context_task(), curl_download_prepare(), download_prepare(), listen_stdio(), listen_stdio(), prepare_daemon(), run_httpd(), schedule_httpd(), schedule_httpd(), and schedule_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SCHEDULER_set_select()

void GNUNET_SCHEDULER_set_select ( GNUNET_SCHEDULER_select  new_select,
void *  new_select_cls 
)

Sets the select function to use in the scheduler (scheduler_select).

Parameters
new_selectnew select function to use (NULL to reset to default)
new_select_clsclosure for new_select
new_selectnew select function to use
new_select_clsclosure for new_select
Returns
previously used select function, NULL for default

Definition at line 452 of file scheduler.c.

454{
455 scheduler_select = new_select;
456 scheduler_select_cls = new_select_cls;
457}
static GNUNET_SCHEDULER_select scheduler_select
Function to use as a select() in the scheduler.
Definition scheduler.c:431
static void * scheduler_select_cls
Closure for scheduler_select.
Definition scheduler.c:441

References scheduler_select, and scheduler_select_cls.

◆ GNUNET_SCHEDULER_begin_async_scope()

void GNUNET_SCHEDULER_begin_async_scope ( struct GNUNET_AsyncScopeId aid)

Change the async scope for the currently executing task and (transitively) for all tasks scheduled by the current task after calling this function.

Nested tasks can begin their own nested async scope.

Once the current task is finished, the async scope ID is reset to its previous value.

Must only be called from a running task.

Parameters
aidthe asynchronous scope id to enter

Definition at line 2585 of file scheduler.c.

2586{
2587 struct GNUNET_AsyncScopeSave dummy_old_scope;
2588
2589 GNUNET_assert (NULL != active_task);
2590 /* Since we're in a task, the context will be automatically
2591 restored by the scheduler. */
2592 GNUNET_async_scope_enter (aid, &dummy_old_scope);
2593}

References active_task, GNUNET_assert, and GNUNET_async_scope_enter().

Here is the call graph for this function: