The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
coord.h File Reference

Coordination thread management. More...

#include <freeradius-devel/io/control.h>
#include <freeradius-devel/io/message.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/semaphore.h>
+ Include dependency graph for coord.h:

Go to the source code of this file.

Data Structures

struct  fr_coord_cb_reg_t
 
struct  fr_coord_reg_ctx_t
 
struct  fr_coord_to_worker_ctx_t
 
struct  fr_coord_worker_cb_reg_t
 
struct  fr_worker_to_coord_ctx_t
 

Macros

#define FR_COORD_CALLBACK_TERMINATOR   { .callback = NULL }
 

Typedefs

typedef fr_coord_cb_inst_t *(* fr_coord_cb_inst_create_t) (TALLOC_CTX *ctx, fr_coord_t *coord, fr_event_list_t *el, bool single_thread, void *uctx)
 
typedef struct fr_coord_cb_inst_s fr_coord_cb_inst_t
 
typedef void(* fr_coord_cb_t) (fr_coord_t *coord, uint32_t worker_id, fr_dbuff_t *dbuff, fr_time_t now, void *plugin_data, void *uctx)
 
typedef struct fr_coord_reg_s fr_coord_reg_t
 
typedef struct fr_coord_s fr_coord_t
 
typedef void(* fr_coord_worker_cb_t) (fr_coord_worker_t *cw, fr_dbuff_t *dbuff, fr_time_t now, void *uctx)
 
typedef struct fr_coord_worker_s fr_coord_worker_t
 

Functions

fr_coord_worker_tfr_coord_attach (TALLOC_CTX *ctx, fr_event_list_t *el, fr_coord_reg_t *coord_reg)
 Attach a worker to a coordinator.
 
void fr_coord_deregister (fr_coord_reg_t *coord_reg)
 De-register a coordinator.
 
int fr_coord_detach (fr_coord_worker_t *cw, bool exiting)
 Signal a coordinator that a worker wants to detach.
 
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_tfr_coord_register (TALLOC_CTX *ctx, 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.
 
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, uint32_t worker_id, uint32_t cb_id, fr_dbuff_t *dbuff)
 Send generic data from a coordinator to a worker.
 
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.
 

Detailed Description

Coordination thread management.

Id
f93afd986e308bf1c181410b61234ea58b8be6ec

Definition in file coord.h.


Data Structure Documentation

◆ fr_coord_cb_reg_t

struct fr_coord_cb_reg_t

Definition at line 44 of file coord.h.

+ Collaboration diagram for fr_coord_cb_reg_t:
Data Fields
fr_coord_cb_t callback
fr_coord_cb_inst_create_t inst_create
char const * name
void * uctx

◆ fr_coord_reg_ctx_t

struct fr_coord_reg_ctx_t

Definition at line 59 of file coord.h.

+ Collaboration diagram for fr_coord_reg_ctx_t:
Data Fields
fr_coord_cb_reg_t * coord_cb Callbacks for worker -> coordinator messages.
size_t coord_send_size Initial ring buffer size for coordinator -> worker data.

Defaults to 4096 of not set.

char const * name Name for this coordinator.
fr_coord_worker_cb_reg_t * worker_cb Callbacks for coordinator -> worker messages.
size_t worker_send_size Initial ring buffer size for worker -> coordinator data.

Defaults to 4096 if not set.

◆ fr_coord_to_worker_ctx_t

struct fr_coord_to_worker_ctx_t

Definition at line 69 of file coord.h.

+ Collaboration diagram for fr_coord_to_worker_ctx_t:
Data Fields
fr_coord_t * coord
void * uctx

◆ fr_coord_worker_cb_reg_t

struct fr_coord_worker_cb_reg_t

Definition at line 51 of file coord.h.

+ Collaboration diagram for fr_coord_worker_cb_reg_t:
Data Fields
fr_coord_worker_cb_t callback
char const * name
void * uctx

◆ fr_worker_to_coord_ctx_t

struct fr_worker_to_coord_ctx_t

Definition at line 74 of file coord.h.

+ Collaboration diagram for fr_worker_to_coord_ctx_t:
Data Fields
fr_coord_worker_t * cw
void * uctx

Macro Definition Documentation

◆ FR_COORD_CALLBACK_TERMINATOR

#define FR_COORD_CALLBACK_TERMINATOR   { .callback = NULL }

Definition at line 57 of file coord.h.

Typedef Documentation

◆ fr_coord_cb_inst_create_t

typedef fr_coord_cb_inst_t *(* fr_coord_cb_inst_create_t) (TALLOC_CTX *ctx, fr_coord_t *coord, fr_event_list_t *el, bool single_thread, void *uctx)

Definition at line 42 of file coord.h.

◆ fr_coord_cb_inst_t

Definition at line 38 of file coord.h.

◆ fr_coord_cb_t

typedef void(* fr_coord_cb_t) (fr_coord_t *coord, uint32_t worker_id, fr_dbuff_t *dbuff, fr_time_t now, void *plugin_data, void *uctx)

Definition at line 40 of file coord.h.

◆ fr_coord_reg_t

Definition at line 34 of file coord.h.

◆ fr_coord_t

typedef struct fr_coord_s fr_coord_t

Definition at line 36 of file coord.h.

◆ fr_coord_worker_cb_t

typedef void(* fr_coord_worker_cb_t) (fr_coord_worker_t *cw, fr_dbuff_t *dbuff, fr_time_t now, void *uctx)

Definition at line 41 of file coord.h.

◆ fr_coord_worker_t

Definition at line 37 of file coord.h.

Function Documentation

◆ fr_coord_attach()

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.

Parameters
ctxTo allocate worker structure in
elEvent list for control messages
coord_regCoordinator registration to attach to.
Returns
  • Worker structure for coordinator use on success
  • NULL on failure

Definition at line 628 of file coord.c.

+ Here is the call graph for this function:

◆ fr_coord_deregister()

void fr_coord_deregister ( fr_coord_reg_t coord_reg)

De-register a coordinator.

To be called from mod_detach of a module which uses a coordinator

When running in threaded mode, will wait for the coordinator to exit.

Parameters
coord_regto de-register

Definition at line 167 of file coord.c.

+ Here is the call graph for this function:

◆ fr_coord_detach()

int fr_coord_detach ( fr_coord_worker_t cw,
bool  exiting 
)

Signal a coordinator that a worker wants to detach.

Parameters
cwWorker which is detaching.
exitingIs the server exiting.

Definition at line 589 of file coord.c.

+ Here is the call graph for this function:

◆ fr_coord_post_event_insert()

int fr_coord_post_event_insert ( fr_event_list_t el)

Insert instance specific post-event callbacks.

Definition at line 796 of file coord.c.

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

◆ fr_coord_pre_event_insert()

int fr_coord_pre_event_insert ( fr_event_list_t el)

Insert instance specific pre-event callbacks.

Definition at line 771 of file coord.c.

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

◆ fr_coord_register()

fr_coord_reg_t * fr_coord_register ( TALLOC_CTX *  ctx,
fr_coord_reg_ctx_t reg_ctx 
)

Register a coordinator.

To be called from mod_instantiate of a module which uses a coordinator

Parameters
ctxto allocate registration under
reg_ctxRegistration data
Returns
  • coordination registration on success
  • NULL on failure

Definition at line 135 of file coord.c.

+ Here is the call graph for this function:

◆ fr_coord_start()

int fr_coord_start ( uint32_t  num_workers,
fr_sem_t sem 
)

Start all registered coordinator threads in multi-threaded mode.

Parameters
num_workersThe number of workers which will be attaching
semSemaphore to use signalling the threads are ready
Returns
  • 0 on success
  • -1 on failure

Definition at line 490 of file coord.c.

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

◆ fr_coord_to_worker_broadcast()

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.

Parameters
coordCoordinator which is sending the data.
cb_idCallback ID for the workers to run.
dbuffBuffer containing data to send.
Returns
  • 0 on success
  • <0 on failure - indicating the number of sends which failed.

Definition at line 724 of file coord.c.

+ Here is the call graph for this function:

◆ fr_coord_to_worker_send()

int fr_coord_to_worker_send ( fr_coord_t coord,
uint32_t  worker_id,
uint32_t  cb_id,
fr_dbuff_t dbuff 
)

Send generic data from a coordinator to a worker.

Parameters
coordCoordinator which is sending the data.
worker_idWorker to send data to.
cb_idCallback ID for the worker to run.
dbuffBuffer containing data to send.
Returns
  • 0 on success
  • <0 on failure

Definition at line 691 of file coord.c.

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

◆ fr_coords_create()

int fr_coords_create ( TALLOC_CTX *  ctx,
fr_event_list_t el 
)

Start coordinators in single threaded mode.

Definition at line 558 of file coord.c.

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

◆ fr_coords_destroy()

void fr_coords_destroy ( void  )

Clean up coordinators in single threaded mode.

Definition at line 540 of file coord.c.

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

◆ fr_worker_to_coord_send()

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.

Parameters
cwWorker side of coordinator sending the data.
cb_idCallback ID for the coordinator to run.
dbuffBuffer containing data to send.
Returns
  • 0 on success
  • < 0 on failure

Definition at line 746 of file coord.c.

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