The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
coord_pair.c File Reference

Sending pair lists to and from coordination threads. More...

#include <freeradius-devel/internal/internal.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/coord_pair.h>
#include <freeradius-devel/io/coord_priv.h>
#include <freeradius-devel/server/main_config.h>
#include <freeradius-devel/unlang/base.h>
+ Include dependency graph for coord_pair.c:

Go to the source code of this file.

Data Structures

struct  fr_coord_packet_ctx_t
 Packet context used when coordinator messages are processed through an interpreter. More...
 
struct  fr_coord_pair_s
 

Functions

static _Atomic (uint64_t)
 Registration of pair list callbacks.
 
static int _coord_pair_reg_free (fr_coord_pair_reg_t *to_free)
 Remove a coord pair registration from the list when it is freed.
 
static int _coord_pair_request_deinit (request_t *request, UNUSED void *uctx)
 
static void _coord_pair_request_detach (request_t *request, void *uctx)
 Make us responsible for running the request.
 
static void _coord_pair_request_done_detached (request_t *request, UNUSED rlm_rcode_t rcode, UNUSED void *uctx)
 Detached request (i.e.
 
static void _coord_pair_request_done_external (UNUSED request_t *request, UNUSED rlm_rcode_t rcode, UNUSED void *uctx)
 External request is now complete - will never happen with coordinators.
 
static void _coord_pair_request_done_internal (request_t *request, UNUSED rlm_rcode_t rcode, void *uctx)
 Internal request (i.e.
 
static void _coord_pair_request_internal_init (request_t *request, void *uctx)
 
static void _coord_pair_request_prioritise (request_t *request, void *uctx)
 Update a request's priority.
 
static void _coord_pair_request_resume (request_t *request, UNUSED void *uctx)
 Interpreter is starting to work on request again.
 
static void _coord_pair_request_runnable (request_t *request, void *uctx)
 Request is now runnable.
 
static bool _coord_pair_request_scheduled (request_t const *request, UNUSED void *uctx)
 Check if a request is scheduled.
 
static void _coord_pair_request_timeout (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t when, void *uctx)
 Enforce max_request_time.
 
static void _coord_pair_request_yield (request_t *request, UNUSED void *uctx)
 Interpreter yielded request.
 
static void coord_pair_request_bootstrap (fr_coord_pair_t *coord_pair, uint32_t worker_id, fr_dbuff_t *dbuff, fr_time_t now, void *uctx)
 
static void coord_pair_request_init (fr_event_list_t *el, request_t *request, fr_time_t now, void *packet_ctx)
 
static void coord_pair_request_name_number (request_t *request)
 
static void coord_pair_request_time_tracking_end (fr_coord_pair_t *coord_pair, request_t *request, fr_time_t now)
 End time tracking for a request.
 
static int coord_pair_request_time_tracking_start (fr_coord_pair_t *coord_pair, request_t *request, fr_time_t now)
 Start time tracking for a request, and mark it as runnable.
 
static int8_t coord_pair_runnable_cmp (void const *one, void const *two)
 Compare two requests by priority and sequence.
 
static void coord_pair_stop_request (request_t *request)
 Signal the unlang interpreter that it needs to stop running the request.
 
static void coord_run_request (fr_coord_pair_t *coord_pair, fr_time_t start)
 
static fr_coord_pair_tfr_coord_pair_create (TALLOC_CTX *ctx, fr_coord_t *coord, fr_event_list_t *el, bool single_thread, void *uctx)
 Create the coord_pair coord instance data.
 
void fr_coord_pair_data_recv (UNUSED fr_coord_t *coord, uint32_t worker_id, fr_dbuff_t *dbuff, fr_time_t now, void *inst, void *uctx)
 Callback run when a coordinator receives pair list data.
 
static void fr_coord_pair_event (UNUSED fr_event_list_t *el, void *uctx)
 Event callback in multi threaded mode.
 
fr_coord_cb_inst_tfr_coord_pair_inst_create (TALLOC_CTX *ctx, fr_coord_t *coord, fr_event_list_t *el, bool single_thread, void *uctx)
 Plugin creation called during coordinator creation.
 
static void fr_coord_pair_post_event (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 
static int fr_coord_pair_pre_event (UNUSED fr_time_t now, UNUSED fr_time_delta_t wake, void *uctx)
 
uint32_t fr_coord_pair_reg_cb_id (fr_coord_pair_reg_t *coord_pair_reg)
 Return the coordinator callback ID associated with a coord_pair_reg_t.
 
fr_coord_pair_reg_tfr_coord_pair_register (TALLOC_CTX *ctx, fr_coord_pair_reg_ctx_t *reg_ctx)
 Register a set of callbacks for pair list based coordinator messages.
 
static int fr_coord_pair_request_timeout_set (fr_coord_pair_t *coord_pair, request_t *request, fr_time_delta_t timeout)
 Set, or re-set the request timer.
 
int fr_coord_to_worker_reply_send (request_t *request, uint32_t worker_id)
 Send a reply list from a coordinator to a worker.
 
void fr_coord_worker_pair_data_recv (fr_coord_worker_t *cw, fr_dbuff_t *dbuff, fr_time_t now, void *uctx)
 Callback run when a worker receives pair list data.
 
int fr_worker_to_coord_pair_send (fr_coord_worker_t *cw, fr_coord_pair_reg_t *coord_pair_reg, fr_pair_list_t *list)
 Send a pair list from a worker to a coordinator.
 

Variables

static const conf_parser_t request_reuse_config []
 Conf parser to read slab settings from module config.
 

Detailed Description

Sending pair lists to and from coordination threads.

Id
d116ad620a109a0a53505763b64f93e24cac018d

Definition in file coord_pair.c.


Data Structure Documentation

◆ fr_coord_packet_ctx_t

struct fr_coord_packet_ctx_t

Packet context used when coordinator messages are processed through an interpreter.

Allows access to the coordinator structure and arbitrary data throughout the state machine.

Definition at line 77 of file coord_pair.c.

+ Collaboration diagram for fr_coord_packet_ctx_t:
Data Fields
fr_coord_pair_t * coord_pair Coordinator pair this packet is for.
void * uctx Source specific ctx.

◆ fr_coord_pair_s

struct fr_coord_pair_s

Definition at line 58 of file coord_pair.c.

+ Collaboration diagram for fr_coord_pair_s:
Data Fields
fr_coord_t * coord Coordinator which this coord pair is attached to.
fr_coord_pair_reg_t * coord_pair_reg Registration details for this coord pair.
fr_event_list_t * el Event list for interpreter.
unlang_interpret_t * intp Interpreter for running requests.
uint64_t num_active Number of active requests.
fr_time_delta_t predicted How long we predict a request will take to execute.
fr_heap_t * runnable Current runnable requests.
request_slab_list_t * slab slab allocator for request_t
fr_timer_list_t * timeout Track when requests timeout using a dlist.
fr_time_tracking_t tracking How much time the coordinator has spent doing things.

Function Documentation

◆ _Atomic()

static _Atomic ( uint64_t  )
static

Registration of pair list callbacks.

< Entry in list of pair list registrations

< Attribute containing packet type

< Pair list decoding root attribute

< Array of pointers to callbacks

< Largest valid value for packet type

< The coordinator callback ID used for pair list handling

< Maximum time for coordinator request processing.

< Request slab allocation config.

< Virtual server containing coordinator process sections.

Definition at line 34 of file coord_pair.c.

◆ _coord_pair_reg_free()

static int _coord_pair_reg_free ( fr_coord_pair_reg_t to_free)
static

Remove a coord pair registration from the list when it is freed.

Definition at line 91 of file coord_pair.c.

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

◆ _coord_pair_request_deinit()

static int _coord_pair_request_deinit ( request_t request,
UNUSED void *  uctx 
)
static

Definition at line 334 of file coord_pair.c.

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

◆ _coord_pair_request_detach()

static void _coord_pair_request_detach ( request_t request,
void *  uctx 
)
static

Make us responsible for running the request.

Definition at line 465 of file coord_pair.c.

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

◆ _coord_pair_request_done_detached()

static void _coord_pair_request_done_detached ( request_t request,
UNUSED rlm_rcode_t  rcode,
UNUSED void *  uctx 
)
static

Detached request (i.e.

one generated by the interpreter with no parent) is now complete

As the request has no parent, then there's nothing to free it so we have to.

Definition at line 451 of file coord_pair.c.

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

◆ _coord_pair_request_done_external()

static void _coord_pair_request_done_external ( UNUSED request_t request,
UNUSED rlm_rcode_t  rcode,
UNUSED void *  uctx 
)
static

External request is now complete - will never happen with coordinators.

Definition at line 426 of file coord_pair.c.

+ Here is the caller graph for this function:

◆ _coord_pair_request_done_internal()

static void _coord_pair_request_done_internal ( request_t request,
UNUSED rlm_rcode_t  rcode,
void *  uctx 
)
static

Internal request (i.e.

one generated by the interpreter) is now complete

Whatever generated the request is now responsible for freeing it.

Definition at line 435 of file coord_pair.c.

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

◆ _coord_pair_request_internal_init()

static void _coord_pair_request_internal_init ( request_t request,
void *  uctx 
)
static

Definition at line 401 of file coord_pair.c.

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

◆ _coord_pair_request_prioritise()

static void _coord_pair_request_prioritise ( request_t request,
void *  uctx 
)
static

Update a request's priority.

Definition at line 531 of file coord_pair.c.

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

◆ _coord_pair_request_resume()

static void _coord_pair_request_resume ( request_t request,
UNUSED void *  uctx 
)
static

Interpreter is starting to work on request again.

Definition at line 514 of file coord_pair.c.

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

◆ _coord_pair_request_runnable()

static void _coord_pair_request_runnable ( request_t request,
void *  uctx 
)
static

Request is now runnable.

Definition at line 494 of file coord_pair.c.

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

◆ _coord_pair_request_scheduled()

static bool _coord_pair_request_scheduled ( request_t const *  request,
UNUSED void *  uctx 
)
static

Check if a request is scheduled.

Definition at line 523 of file coord_pair.c.

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

◆ _coord_pair_request_timeout()

static void _coord_pair_request_timeout ( UNUSED fr_timer_list_t tl,
UNUSED fr_time_t  when,
void *  uctx 
)
static

Enforce max_request_time.

Parameters
[in]tlthe coordinators's timer list.
[in]whenthe current time
[in]uctxthe request_t timing out.

Definition at line 246 of file coord_pair.c.

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

◆ _coord_pair_request_yield()

static void _coord_pair_request_yield ( request_t request,
UNUSED void *  uctx 
)
static

Interpreter yielded request.

Definition at line 505 of file coord_pair.c.

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

◆ coord_pair_request_bootstrap()

static void coord_pair_request_bootstrap ( fr_coord_pair_t coord_pair,
uint32_t  worker_id,
fr_dbuff_t dbuff,
fr_time_t  now,
void *  uctx 
)
static

Definition at line 339 of file coord_pair.c.

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

◆ coord_pair_request_init()

static void coord_pair_request_init ( fr_event_list_t el,
request_t request,
fr_time_t  now,
void *  packet_ctx 
)
inlinestatic

Definition at line 313 of file coord_pair.c.

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

◆ coord_pair_request_name_number()

static void coord_pair_request_name_number ( request_t request)
inlinestatic

Definition at line 327 of file coord_pair.c.

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

◆ coord_pair_request_time_tracking_end()

static void coord_pair_request_time_tracking_end ( fr_coord_pair_t coord_pair,
request_t request,
fr_time_t  now 
)
static

End time tracking for a request.

Definition at line 301 of file coord_pair.c.

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

◆ coord_pair_request_time_tracking_start()

static int coord_pair_request_time_tracking_start ( fr_coord_pair_t coord_pair,
request_t request,
fr_time_t  now 
)
static

Start time tracking for a request, and mark it as runnable.

Definition at line 278 of file coord_pair.c.

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

◆ coord_pair_runnable_cmp()

static int8_t coord_pair_runnable_cmp ( void const *  one,
void const *  two 
)
static

Compare two requests by priority and sequence.

Definition at line 546 of file coord_pair.c.

+ Here is the caller graph for this function:

◆ coord_pair_stop_request()

static void coord_pair_stop_request ( request_t request)
static

Signal the unlang interpreter that it needs to stop running the request.

Parameters
[in]requestrequest to cancel. The request may still run to completion.

Definition at line 235 of file coord_pair.c.

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

◆ coord_run_request()

static void coord_run_request ( fr_coord_pair_t coord_pair,
fr_time_t  start 
)
inlinestatic

Definition at line 615 of file coord_pair.c.

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

◆ fr_coord_pair_create()

static fr_coord_pair_t * fr_coord_pair_create ( TALLOC_CTX *  ctx,
fr_coord_t coord,
fr_event_list_t el,
bool  single_thread,
void *  uctx 
)
static

Create the coord_pair coord instance data.

Definition at line 559 of file coord_pair.c.

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

◆ fr_coord_pair_data_recv()

void fr_coord_pair_data_recv ( UNUSED fr_coord_t coord,
uint32_t  worker_id,
fr_dbuff_t dbuff,
fr_time_t  now,
void *  inst,
void *  uctx 
)

Callback run when a coordinator receives pair list data.

Converts the data into a request.

Definition at line 666 of file coord_pair.c.

+ Here is the call graph for this function:

◆ fr_coord_pair_event()

static void fr_coord_pair_event ( UNUSED fr_event_list_t el,
void *  uctx 
)
static

Event callback in multi threaded mode.

Definition at line 655 of file coord_pair.c.

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

◆ fr_coord_pair_inst_create()

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

Plugin creation called during coordinator creation.

Parameters
ctxto allocate the plugin in.
elEvent list for plugin to use.
single_threadis the server in single thread mode.
uctxconfigured for the callback this plugin relates to.
Returns
  • fr_coord_plugin_t on success
  • NULL on failure

Definition at line 783 of file coord_pair.c.

+ Here is the call graph for this function:

◆ fr_coord_pair_post_event()

static void fr_coord_pair_post_event ( UNUSED fr_event_list_t el,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Definition at line 646 of file coord_pair.c.

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

◆ fr_coord_pair_pre_event()

static int fr_coord_pair_pre_event ( UNUSED fr_time_t  now,
UNUSED fr_time_delta_t  wake,
void *  uctx 
)
static

Definition at line 637 of file coord_pair.c.

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

◆ fr_coord_pair_reg_cb_id()

uint32_t fr_coord_pair_reg_cb_id ( fr_coord_pair_reg_t coord_pair_reg)

Return the coordinator callback ID associated with a coord_pair_reg_t.

Definition at line 220 of file coord_pair.c.

◆ fr_coord_pair_register()

fr_coord_pair_reg_t * fr_coord_pair_register ( TALLOC_CTX *  ctx,
fr_coord_pair_reg_ctx_t reg_ctx 
)

Register a set of callbacks for pair list based coordinator messages.

Returns a structure to pass as uctx to fr_coord_cb_t using the macro FR_COORD_PAIR_CB_CTX_SET.

Parameters
ctxto allocate the registration under.
reg_ctxCallback details to register.

Definition at line 113 of file coord_pair.c.

+ Here is the call graph for this function:

◆ fr_coord_pair_request_timeout_set()

static int fr_coord_pair_request_timeout_set ( fr_coord_pair_t coord_pair,
request_t request,
fr_time_delta_t  timeout 
)
static

Set, or re-set the request timer.

Parameters
[in]coord_pairthe coord_pair_t containing the timeout lists.
[in]requestthat we're timing out.
[in]timeoutthe timeout to set.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 265 of file coord_pair.c.

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

◆ fr_coord_to_worker_reply_send()

int fr_coord_to_worker_reply_send ( request_t request,
uint32_t  worker_id 
)

Send a reply list from a coordinator to a worker.

Parameters
requestcontaining the reply to send.
worker_idto send the reply to.
Returns
  • 0 on success
  • -1 on failure

Definition at line 724 of file coord_pair.c.

+ Here is the call graph for this function:

◆ fr_coord_worker_pair_data_recv()

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

Callback run when a worker receives pair list data.

Finds the packet type attribute in the data and calls the callback registered against the value of that attribute.

Parameters
cwWorker which received the message.
dbuffData received.
nowTime the data is received.
uctxThe coord_pair registration.

Definition at line 685 of file coord_pair.c.

+ Here is the call graph for this function:

◆ fr_worker_to_coord_pair_send()

int fr_worker_to_coord_pair_send ( fr_coord_worker_t cw,
fr_coord_pair_reg_t coord_pair_reg,
fr_pair_list_t list 
)

Send a pair list from a worker to a coordinator.

The pair list must include an attribute indicating the packet type

Parameters
cwThe coord worker sending the data.
listof pairs to send.
Returns
  • 0 on success
  • -1 on failure

Definition at line 755 of file coord_pair.c.

+ Here is the call graph for this function:

Variable Documentation

◆ request_reuse_config

const conf_parser_t request_reuse_config[]
static
Initial value:
= {
}
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:657
#define FR_SLAB_CONFIG_CONF_PARSER
conf_parser_t entries to populate user configurable slab values
Definition slab.h:35

Conf parser to read slab settings from module config.

Definition at line 84 of file coord_pair.c.