OpenDNSSEC-enforcer  2.0.4
Functions
schedule.c File Reference
#include "config.h"
#include <ldns/ldns.h>
#include <pthread.h>
#include <signal.h>
#include "scheduler/schedule.h"
#include "scheduler/task.h"
#include "duration.h"
#include "log.h"

Go to the source code of this file.

Functions

schedule_typeschedule_create ()
 
void schedule_cleanup (schedule_type *schedule)
 
time_t schedule_time_first (schedule_type *schedule)
 
size_t schedule_taskcount (schedule_type *schedule)
 
void schedule_flush (schedule_type *schedule)
 
int schedule_flush_type (schedule_type *schedule, task_id id)
 
void schedule_purge (schedule_type *schedule)
 
task_typeschedule_pop_task (schedule_type *schedule)
 
task_typeschedule_pop_first_task (schedule_type *schedule)
 
ods_status schedule_task (schedule_type *schedule, task_type *task)
 
void schedule_release_all (schedule_type *schedule)
 

Function Documentation

◆ schedule_cleanup()

void schedule_cleanup ( schedule_type schedule)

Clean up schedule. deinitialise and free scheduler. Threads MUST be stopped before calling this function.

Definition at line 220 of file schedule.c.

References ods_log_debug().

Referenced by engine_dealloc().

◆ schedule_create()

schedule_type* schedule_create ( void  )

Create new schedule. Allocate and initialise scheduler. To clean up schedule_cleanup() should be called.

Definition at line 189 of file schedule.c.

References ods_log_error().

Referenced by engine_alloc().

◆ schedule_flush()

void schedule_flush ( schedule_type schedule)

Flush schedule.

Parameters
[in]scheduleschedule to be flushed

Definition at line 273 of file schedule.c.

References ods_log_debug().

◆ schedule_flush_type()

int schedule_flush_type ( schedule_type schedule,
task_id  id 
)

Flush schedule for a specific type of task.

Parameters
[in]scheduleschedule to be flushed
Returns
number of tasks flushed

Definition at line 298 of file schedule.c.

References ods_log_debug().

Referenced by flush_resalt_task().

◆ schedule_pop_first_task()

task_type* schedule_pop_first_task ( schedule_type schedule)

Pop the first scheduled task. regardless of its due time.

Parameters
[in]scheduleschedule
Returns
task_type* popped task, or NULL when no task available or no task available

Definition at line 390 of file schedule.c.

References schedule_struct::schedule_lock.

◆ schedule_pop_task()

task_type* schedule_pop_task ( schedule_type schedule)

Pop the first scheduled task that is due. If an item is directly available it will be returned. Else the call will block and return NULL when the caller is awoken.

Parameters
[in]scheduleschedule
Returns
task_type* popped task, or NULL when no task available or no task due

Definition at line 370 of file schedule.c.

References schedule_struct::schedule_lock.

Referenced by worker_start().

◆ schedule_purge()

void schedule_purge ( schedule_type schedule)

purge schedule. All tasks will be thrashed.

Parameters
[in]scheduleschedule to be purged

Definition at line 342 of file schedule.c.

References schedule_struct::schedule_lock, task_cleanup(), schedule_struct::tasks, and schedule_struct::tasks_by_name.

◆ schedule_release_all()

void schedule_release_all ( schedule_type schedule)

Wake up all threads waiting for tasks. Useful to on program teardown.

Definition at line 475 of file schedule.c.

References schedule_struct::schedule_cond, and schedule_struct::schedule_lock.

◆ schedule_task()

ods_status schedule_task ( schedule_type schedule,
task_type task 
)

Schedule task.

Parameters
[in]scheduleschedule
[in]tasktask
Returns
ods_status status

Task is already in tasks_by_name queue, so we must update it in tasks queue

Definition at line 401 of file schedule.c.

References ods_log_error().

Referenced by flush_resalt_task().

◆ schedule_taskcount()

size_t schedule_taskcount ( schedule_type schedule)

Number of task in schedule

Parameters
[in]scheduleschedule
Returns
task count, 0 on empty or error;

Definition at line 266 of file schedule.c.

References schedule_struct::tasks.

◆ schedule_time_first()

time_t schedule_time_first ( schedule_type schedule)

exported convenience functions should all be thread safe

Definition at line 246 of file schedule.c.

References schedule_struct::schedule_lock, and schedule_struct::tasks.