![]() |
The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
|
Coordination thread management. More...
#include <freeradius-devel/io/listen.h>#include <freeradius-devel/io/schedule.h>#include <freeradius-devel/io/thread.h>#include <freeradius-devel/io/coord_priv.h>#include <freeradius-devel/unlang/base.h>#include <freeradius-devel/util/syserror.h>#include <stdalign.h>
Include dependency graph for coord.c:Go to the source code of this file.
Data Structures | |
| struct | fr_coord_reg_s |
| A coordinator registration. More... | |
| struct | fr_coord_s |
| A coordinator which receives messages from workers. More... | |
| struct | fr_coord_worker_attach_msg_t |
| Control plane message used for workers attaching / detaching to coordinators. More... | |
| struct | fr_coord_worker_detach_msg_t |
| struct | fr_coord_worker_s |
| The worker end of worker <-> coordinator communication. More... | |
| struct | fr_schedule_coord_t |
| Scheduler specific information for coordinator threads. More... | |
Macros | |
| #define | FR_CONTROL_ID_COORD_DATA (4) |
| Worker <-> coordinator message to pass data to a callback. | |
| #define | FR_CONTROL_ID_COORD_WORKER_ACK (3) |
| Message sent to worker to acknowledge attach / detach. | |
| #define | FR_CONTROL_ID_COORD_WORKER_ATTACH (1) |
| Message sent from worker to attach to a coordinator. | |
| #define | FR_CONTROL_ID_COORD_WORKER_DETACH (2) |
| Message sent from worker to detach from a coordinator. | |
| #define | MIN_WORKER_ID -1 |
| The minimum value we expect as worker id. -1 is the main thread. | |
Functions | |
| static fr_cmp_ret_t | coord_cmp (void const *one, void const *two) |
| Compare coordinators by registration. | |
| static void | coord_data_recv (void const *data, size_t data_size, fr_time_t now, void *uctx) |
| Callback for a coordinator receiving data from a worker. | |
| static void | coord_worker_attach (void const *data, NDEBUG_UNUSED size_t data_size, UNUSED fr_time_t now, void *uctx) |
| Callback run by a coordinator when a worker attaches. | |
| static void | coord_worker_data_recv (void const *data, size_t data_size, fr_time_t now, void *uctx) |
| Callback for a worker receiving data from a coordinator. | |
| static void | coord_worker_detach (void const *data, NDEBUG_UNUSED size_t data_size, UNUSED fr_time_t now, void *uctx) |
| Callback run by a coordinator when a worker detaches. | |
| static void | coordinate_worker_ack (NDEBUG_UNUSED void const *data, NDEBUG_UNUSED size_t data_size, UNUSED fr_time_t now, UNUSED void *uctx) |
| A worker got an ack from a coordinator in response to attach / detach. | |
| fr_coord_worker_t * | fr_coord_attach (TALLOC_CTX *ctx, fr_event_list_t *el, fr_coord_reg_t *coord_reg) |
| Attach a worker to a coordinator. | |
| int | fr_coord_close_event_insert (fr_event_list_t *el) |
| static void | fr_coord_close_post_event (fr_event_list_t *el, UNUSED fr_time_t now, UNUSED void *uctx) |
| Event loop callback to exit the loop when all workers have detached from all coordinators. | |
| static fr_coord_t * | fr_coord_create (TALLOC_CTX *ctx, fr_event_list_t *el, fr_coord_reg_t *coord_reg, bool single_thread, uint32_t max_workers) |
| Create a coordinator from its registration. | |
| void | fr_coord_deregister (fr_coord_reg_t *coord_reg) |
| De-register a coordinator. | |
| static void | fr_coord_destroy (fr_coord_t *coord) |
| int | fr_coord_detach (fr_coord_worker_t *cw, bool exiting) |
| Signal a coordinator that a worker wants to detach. | |
| char const * | fr_coord_name (fr_coord_t const *coord) |
| Return the coordinator name. | |
| int | fr_coord_post_event_insert (fr_event_list_t *el) |
| Insert instance specific post-event callbacks. | |
| int | fr_coord_pre_event_insert (fr_event_list_t *el) |
| Insert instance specific pre-event callbacks. | |
| fr_coord_reg_t * | fr_coord_register (fr_coord_reg_ctx_t *reg_ctx) |
| Register a coordinator. | |
| int | fr_coord_start (uint32_t num_workers, fr_sem_t *sem) |
| Start all registered coordinator threads in multi-threaded mode. | |
| void | fr_coord_thread_join (void) |
| Wait for all the coordinator threads to exit. | |
| int | fr_coord_to_worker_broadcast (fr_coord_t *coord, uint32_t cb_id, fr_dbuff_t *dbuff) |
| Broadcast data from a coordinator to all workers. | |
| int | fr_coord_to_worker_send (fr_coord_t *coord, int32_t worker_id, uint32_t cb_id, fr_dbuff_t *dbuff) |
| Send generic data from a coordinator to a worker. | |
| static void | fr_coordinate (fr_coord_t *coord) |
| Run the event loop for a coordinator thread when in multi-threaded mode. | |
| static void * | fr_coordinate_thread (void *arg) |
| Entry point for a coordinator thread. | |
| int | fr_coords_create (TALLOC_CTX *ctx, fr_event_list_t *el) |
| Start coordinators in single threaded mode. | |
| void | fr_coords_destroy (void) |
| Clean up coordinators in single threaded mode. | |
| int | fr_worker_to_coord_send (fr_coord_worker_t *cw, uint32_t cb_id, fr_dbuff_t *dbuff) |
| Send data from a worker to a coordinator. | |
Variables | |
| static fr_dlist_head_t * | coord_regs = NULL |
| static fr_dlist_head_t * | coord_threads = NULL |
| static fr_rb_tree_t | coords = (fr_rb_tree_t){ .num_elements = 0 } |
Coordination thread management.
Definition in file coord.c.
| struct fr_coord_reg_s |
Collaboration diagram for fr_coord_reg_s:| Data Fields | ||
|---|---|---|
| fr_coord_cb_reg_t * | coord_cb | Callbacks for worker -> coordinator messages. |
| size_t | coord_send_size | Initial size for coordinator -> worker ring buffer. |
| fr_dlist_t | entry | Entry in list of registrations. |
| module_instance_t const * | mi | Module instance which registered this coordinator. |
| char const * | name | Name for debugging. |
| fr_coord_worker_cb_reg_t * | worker_cb | Callbacks for coordinator -> worker messages. |
| size_t | worker_send_size | Initial size for worker -> coordinator ring buffer. |
| struct fr_coord_s |
Collaboration diagram for fr_coord_s:| Data Fields | ||
|---|---|---|
| fr_coord_cb_reg_t * | callbacks | Array of callbacks for worker -> coordinator messages. |
| fr_coord_cb_inst_t ** | cb_inst | Array of callback instance specific data. |
| fr_atomic_queue_t * | coord_recv_aq | Atomic queue for worker -> coordinator. |
| fr_control_t * | coord_recv_control | Control plane for worker -> coordinator messages. |
| fr_coord_reg_t * | coord_reg | Coordinator registration details. |
| fr_atomic_queue_t ** | coord_send_aq | Atomic queues for coordinator -> worker data. |
| fr_control_t ** | coord_send_control | Control planes for coordinator -> worker messages. |
| fr_message_set_t ** | coord_send_ms | Message sets for coordinator -> worker data. |
| fr_ring_buffer_t ** | coord_send_rb | Ring buffers for coordinator -> worker control messages. |
| fr_event_list_t * | el | Coordinator event list. |
| bool | exiting | Is this coordinator shutting down. |
| uint32_t | max_workers | Maximum number of workers we expect. |
| fr_rb_node_t | node | Entry in the tree of coordinators. |
| uint32_t | num_callbacks | Number of callbacks defined. |
| uint32_t | num_workers | How many workers are attached. |
| bool | single_thread | Are we in single thread mode. |
| struct fr_coord_worker_attach_msg_t |
Control plane message used for workers attaching / detaching to coordinators.
Collaboration diagram for fr_coord_worker_attach_msg_t:| Data Fields | ||
|---|---|---|
| int32_t | worker | Worker ID. |
| fr_atomic_queue_t * | worker_recv_aq | Atomic queue to send data to this worker. |
| fr_control_t * | worker_recv_control | Control plane to send messages to this worker. |
| struct fr_coord_worker_detach_msg_t |
| struct fr_coord_worker_s |
Collaboration diagram for fr_coord_worker_s:| Data Fields | ||
|---|---|---|
| fr_coord_worker_cb_reg_t * | callbacks | Callbacks for coordinator -> worker messages. |
| fr_coord_t * | coord | Coordinator this worker is related to. |
| uint32_t | num_callbacks | Number of callbacks registered. |
| fr_atomic_queue_t * | worker_recv_aq | Atomic queue for coordinator -> worker messages. |
| fr_control_t * | worker_recv_control | Coordinator -> worker control plane. |
| fr_message_set_t * | worker_send_ms | Message set for worker -> coordinator messages. |
| fr_ring_buffer_t * | worker_send_rb | Ring buffer for worker -> coordinator control plane. |
| struct fr_schedule_coord_t |
Collaboration diagram for fr_schedule_coord_t:| Data Fields | ||
|---|---|---|
| fr_coord_t * | coord | The coordinator data structure. |
| fr_coord_reg_t * | coord_reg | Coordinator registration details. |
| uint32_t | max_workers | Maximum number of workers which will connect to this coordinator. |
| fr_sem_t * | sem | For inter-thread signaling. |
| fr_thread_t | thread | common thread information - must be first! |
| #define FR_CONTROL_ID_COORD_DATA (4) |
| #define FR_CONTROL_ID_COORD_WORKER_ACK (3) |
| #define FR_CONTROL_ID_COORD_WORKER_ATTACH (1) |
| #define FR_CONTROL_ID_COORD_WORKER_DETACH (2) |
| #define MIN_WORKER_ID -1 |
|
static |
|
static |
|
static |
|
static |
| fr_coord_worker_t * fr_coord_attach | ( | TALLOC_CTX * | ctx, |
| fr_event_list_t * | el, | ||
| fr_coord_reg_t * | coord_reg | ||
| ) |
Attach a worker to a coordinator.
| ctx | To allocate worker structure in |
| el | Event list for control messages |
| coord_reg | Coordinator registration to attach to. |
Definition at line 691 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int fr_coord_close_event_insert | ( | fr_event_list_t * | el | ) |
|
static |
Event loop callback to exit the loop when all workers have detached from all coordinators.
Used during single threaded shut down to allow the event loop to run any tidy up needed by coordinators.
Definition at line 889 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Create a coordinator from its registration.
| ctx | to allocate the coordinator in |
| el | Event list to run this coordinator |
| coord_reg | Registration to configure this coordinator |
| single_thread | Is the server in single thread mode |
| max_workers | The maximum number of workers which will attach |
Definition at line 338 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void fr_coord_deregister | ( | fr_coord_reg_t * | coord_reg | ) |
|
static |
| int fr_coord_detach | ( | fr_coord_worker_t * | cw, |
| bool | exiting | ||
| ) |
| char const * fr_coord_name | ( | fr_coord_t const * | coord | ) |
| int fr_coord_post_event_insert | ( | fr_event_list_t * | el | ) |
| int fr_coord_pre_event_insert | ( | fr_event_list_t * | el | ) |
| fr_coord_reg_t * fr_coord_register | ( | fr_coord_reg_ctx_t * | reg_ctx | ) |
Register a coordinator.
To be called from mod_instantiate of a module which uses a coordinator
| reg_ctx | Registration data |
Definition at line 137 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:Start all registered coordinator threads in multi-threaded mode.
| num_workers | The number of workers which will be attaching |
| sem | Semaphore to use signalling the threads are ready |
Definition at line 553 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void fr_coord_thread_join | ( | void | ) |
| int fr_coord_to_worker_broadcast | ( | fr_coord_t * | coord, |
| uint32_t | cb_id, | ||
| fr_dbuff_t * | dbuff | ||
| ) |
Broadcast data from a coordinator to all workers.
| coord | Coordinator which is sending the data. |
| cb_id | Callback ID for the workers to run. |
| dbuff | Buffer containing data to send. |
Definition at line 789 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int fr_coord_to_worker_send | ( | fr_coord_t * | coord, |
| int32_t | worker_id, | ||
| uint32_t | cb_id, | ||
| fr_dbuff_t * | dbuff | ||
| ) |
Send generic data from a coordinator to a worker.
| coord | Coordinator which is sending the data. |
| worker_id | Worker to send data to. |
| cb_id | Callback ID for the worker to run. |
| dbuff | Buffer containing data to send. |
Definition at line 754 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
| int fr_coords_create | ( | TALLOC_CTX * | ctx, |
| fr_event_list_t * | el | ||
| ) |
| void fr_coords_destroy | ( | void | ) |
| int fr_worker_to_coord_send | ( | fr_coord_worker_t * | cw, |
| uint32_t | cb_id, | ||
| fr_dbuff_t * | dbuff | ||
| ) |
Send data from a worker to a coordinator.
| cw | Worker side of coordinator sending the data. |
| cb_id | Callback ID for the coordinator to run. |
| dbuff | Buffer containing data to send. |
Definition at line 811 of file coord.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
1.9.8