The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Network / worker thread scheduling. More...
#include <freeradius-devel/autoconf.h>
#include <freeradius-devel/io/schedule.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/server/trigger.h>
#include <pthread.h>
Go to the source code of this file.
Data Structures | |
struct | fr_schedule_network_t |
Scheduler specific information for network threads. More... | |
struct | fr_schedule_s |
The scheduler. More... | |
struct | fr_schedule_worker_t |
Scheduler specific information for worker threads. More... | |
Macros | |
#define | LOG_DST sc->log |
#define | SEM_WAIT_INTR(_x) do {if (sem_wait(_x) == 0) break;} while (errno == EINTR) |
#define | SEMAPHORE_LOCKED (0) |
Typedefs | |
typedef enum fr_schedule_child_status_t | fr_schedule_child_status_t |
Track the child thread status. | |
Enumerations | |
enum | fr_schedule_child_status_t { FR_CHILD_FREE = 0 , FR_CHILD_INITIALIZING , FR_CHILD_RUNNING , FR_CHILD_EXITED , FR_CHILD_FAIL } |
Track the child thread status. More... | |
Functions | |
fr_schedule_t * | fr_schedule_create (TALLOC_CTX *ctx, fr_event_list_t *el, fr_log_t *logger, fr_log_lvl_t lvl, fr_schedule_thread_instantiate_t worker_thread_instantiate, fr_schedule_thread_detach_t worker_thread_detach, fr_schedule_config_t *config) |
Create a scheduler and spawn the child threads. | |
int | fr_schedule_destroy (fr_schedule_t **sc_to_free) |
Destroy a scheduler, and tell its child threads to exit. | |
fr_network_t * | fr_schedule_directory_add (fr_schedule_t *sc, fr_listen_t *li) |
Add a directory NOTE_EXTEND to a scheduler. | |
fr_network_t * | fr_schedule_listen_add (fr_schedule_t *sc, fr_listen_t *li) |
Add a fr_listen_t to a scheduler. | |
static void * | fr_schedule_network_thread (void *arg) |
Initialize and run the network thread. | |
int | fr_schedule_pthread_create (pthread_t *thread, void *(*func)(void *), void *arg) |
Creates a new thread using our standard set of options. | |
int | fr_schedule_worker_id (void) |
Return the worker id for the current thread. | |
static void * | fr_schedule_worker_thread (void *arg) |
Entry point for worker threads. | |
static void | stats_timer (fr_event_list_t *el, fr_time_t now, void *uctx) |
Variables | |
static _Thread_local int | worker_id |
Internal ID of the current worker thread. | |
Network / worker thread scheduling.
Definition in file schedule.c.
struct fr_schedule_network_t |
Scheduler specific information for network threads.
Wraps a fr_network_t, tracking additional information that the scheduler uses.
Definition at line 105 of file schedule.c.
Data Fields | ||
---|---|---|
TALLOC_CTX * | ctx | our allocation ctx |
fr_dlist_t | entry | our entry into the linked list of networks |
fr_event_timer_t const * | ev | timer for stats_interval |
unsigned int | id | a unique ID |
fr_network_t * | nr | the receive data structure |
pthread_t | pthread_id | the thread of this network |
fr_schedule_t * | sc | the scheduler we are running under |
fr_schedule_child_status_t | status | status of the worker |
struct fr_schedule_s |
The scheduler.
Definition at line 125 of file schedule.c.
Data Fields | ||
---|---|---|
fr_schedule_config_t * | config | configuration |
CONF_SECTION * | cs | thread pool configuration section |
fr_event_list_t * | el | event list for single-threaded mode. |
fr_log_t * | log | log destination |
fr_log_lvl_t | lvl | log level |
sem_t | network_sem | for inter-thread signaling |
fr_dlist_head_t | networks | list of networks |
unsigned int | num_workers_exited | number of exited workers |
bool | running | is the scheduler running? |
fr_network_t * | single_network | for single-threaded mode |
fr_worker_t * | single_worker | for single-threaded mode |
sem_t | worker_sem | for inter-thread signaling |
fr_schedule_thread_detach_t | worker_thread_detach | |
fr_schedule_thread_instantiate_t | worker_thread_instantiate | thread instantiation callback |
fr_dlist_head_t | workers | list of workers |
struct fr_schedule_worker_t |
Scheduler specific information for worker threads.
Wraps a fr_worker_t, tracking additional information that the scheduler uses.
Definition at line 83 of file schedule.c.
Data Fields | ||
---|---|---|
fr_channel_t * | ch | channel for communicating with the worker |
fr_time_t | cpu_time | how much CPU time this worker has used |
TALLOC_CTX * | ctx | our allocation ctx |
fr_event_list_t * | el | our event list |
fr_dlist_t | entry | our entry into the linked list of workers |
unsigned int | id |
a unique ID ID of the worker 0..N. |
int | id | ID of the worker 0..N. |
pthread_t | pthread_id |
the thread of this worker pthread ID of the worker |
fr_schedule_t * | sc | the scheduler we are running under |
fr_schedule_child_status_t | status | status of the worker |
int | uses | how many network threads are using it |
fr_worker_t * | worker |
the worker data structure pointer to the worker |
Definition at line 27 of file schedule.c.
Definition at line 65 of file schedule.c.
#define SEMAPHORE_LOCKED (0) |
Definition at line 46 of file schedule.c.
typedef enum fr_schedule_child_status_t fr_schedule_child_status_t |
Track the child thread status.
Track the child thread status.
Definition at line 70 of file schedule.c.
fr_schedule_t * fr_schedule_create | ( | TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
fr_log_t * | logger, | ||
fr_log_lvl_t | lvl, | ||
fr_schedule_thread_instantiate_t | worker_thread_instantiate, | ||
fr_schedule_thread_detach_t | worker_thread_detach, | ||
fr_schedule_config_t * | config | ||
) |
Create a scheduler and spawn the child threads.
[in] | ctx | talloc context. |
[in] | el | event list, only for single-threaded mode. |
[in] | logger | destination for all logging messages. |
[in] | lvl | log level. |
[in] | worker_thread_instantiate | callback for new worker threads. |
[in] | worker_thread_detach | callback to destroy resources allocated by worker_thread_instantiate. |
[in] | config | configuration for the scheduler |
Definition at line 463 of file schedule.c.
int fr_schedule_destroy | ( | fr_schedule_t ** | sc_to_free | ) |
Destroy a scheduler, and tell its child threads to exit.
[in] | sc_to_free | the scheduler |
Definition at line 761 of file schedule.c.
fr_network_t * fr_schedule_directory_add | ( | fr_schedule_t * | sc, |
fr_listen_t * | li | ||
) |
Add a directory NOTE_EXTEND to a scheduler.
[in] | sc | the scheduler |
[in] | li | the ctx and callbacks for the transport. |
Definition at line 913 of file schedule.c.
fr_network_t * fr_schedule_listen_add | ( | fr_schedule_t * | sc, |
fr_listen_t * | li | ||
) |
Add a fr_listen_t to a scheduler.
[in] | sc | the scheduler |
[in] | li | the ctx and callbacks for the transport. |
Definition at line 881 of file schedule.c.
|
static |
Initialize and run the network thread.
[in] | arg | the fr_schedule_network_t |
Definition at line 315 of file schedule.c.
int fr_schedule_pthread_create | ( | pthread_t * | thread, |
void *(*)(void *) | func, | ||
void * | arg | ||
) |
Creates a new thread using our standard set of options.
New threads are:
[out] | thread | handled that was created by pthread_create. |
[in] | func | entry point for the thread. |
[in] | arg | Argument to pass to func. |
Definition at line 425 of file schedule.c.
int fr_schedule_worker_id | ( | void | ) |
Return the worker id for the current thread.
Definition at line 157 of file schedule.c.
|
static |
Entry point for worker threads.
[in] | arg | the fr_schedule_worker_t |
Definition at line 167 of file schedule.c.
|
static |
Definition at line 301 of file schedule.c.
|
static |
Internal ID of the current worker thread.
Definition at line 151 of file schedule.c.