![]() |
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>
Include dependency graph for schedule.c: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_timer_list_t *tl, 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.
Collaboration diagram for fr_schedule_network_t:| Data Fields | ||
|---|---|---|
| TALLOC_CTX * | ctx | our allocation ctx |
| fr_dlist_t | entry | our entry into the linked list of networks |
| fr_timer_t * | 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.
Collaboration diagram for fr_schedule_s:| 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.
Collaboration diagram for fr_schedule_worker_t:| 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 466 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 768 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 924 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 892 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Initialize and run the network thread.
| [in] | arg | the fr_schedule_network_t |
Definition at line 318 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 428 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int fr_schedule_worker_id | ( | void | ) |
Return the worker id for the current thread.
Definition at line 157 of file schedule.c.
Here is the caller graph for this function:
|
static |
Entry point for worker threads.
| [in] | arg | the fr_schedule_worker_t |
Definition at line 167 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 304 of file schedule.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Internal ID of the current worker thread.
Definition at line 151 of file schedule.c.
1.9.8