The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
worker.c File Reference

Worker thread functions. More...

#include <freeradius-devel/io/channel.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/worker.h>
#include <freeradius-devel/unlang/base.h>
#include <freeradius-devel/unlang/finally.h>
#include <freeradius-devel/util/minmax_heap.h>
#include <freeradius-devel/util/timer.h>
#include <stdalign.h>
+ Include dependency graph for worker.c:

Go to the source code of this file.

Data Structures

struct  fr_worker_listen_t
 
struct  fr_worker_s
 A worker which takes packets from a master, and processes them. More...
 

Macros

#define CHECK_CONFIG(_x, _min, _max)
 
#define CHECK_CONFIG_TIME_DELTA(_x, _min, _max)
 
#define LOG_DST   worker->log
 
#define LOG_PREFIX   worker->name
 
#define WORKER_VERIFY
 

Functions

static _Atomic (uint64_t)
 
static int _worker_request_deinit (request_t *request, UNUSED void *uctx)
 
static void _worker_request_detach (request_t *request, void *uctx)
 Make us responsible for running the request.
 
static void _worker_request_done_detached (request_t *request, UNUSED rlm_rcode_t rcode, UNUSED void *uctx)
 Detached request (i.e.
 
static void _worker_request_done_external (request_t *request, UNUSED rlm_rcode_t rcode, void *uctx)
 External request is now complete.
 
static void _worker_request_done_internal (request_t *request, UNUSED rlm_rcode_t rcode, void *uctx)
 Internal request (i.e.
 
static void _worker_request_internal_init (request_t *request, void *uctx)
 Internal request (i.e.
 
static void _worker_request_prioritise (request_t *request, void *uctx)
 Update a request's priority.
 
static void _worker_request_resume (request_t *request, UNUSED void *uctx)
 Interpreter is starting to work on request again.
 
static void _worker_request_runnable (request_t *request, void *uctx)
 Request is now runnable.
 
static bool _worker_request_scheduled (request_t const *request, UNUSED void *uctx)
 Check if a request is scheduled.
 
static void _worker_request_timeout (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t when, void *uctx)
 Enforce max_request_time.
 
static void _worker_request_yield (request_t *request, UNUSED void *uctx)
 Interpreter yielded request.
 
static int cmd_stats_worker (FILE *fp, UNUSED FILE *fp_err, void *ctx, fr_cmd_info_t const *info)
 
void fr_worker (fr_worker_t *worker)
 The main loop and entry point of the stand-alone worker thread.
 
fr_worker_t * fr_worker_alloc (TALLOC_CTX *ctx, fr_event_list_t *el, char const *name, fr_log_t const *logger, fr_log_lvl_t lvl, fr_worker_config_t *config)
 Create a worker.
 
fr_channel_t * fr_worker_channel_create (fr_worker_t *worker, TALLOC_CTX *ctx, fr_control_t *master, fr_message_set_t *reply_ms)
 Create a channel to the worker.
 
int fr_worker_close_event_insert (fr_worker_t *worker)
 Add events to the loop which will send close ack to the network.
 
fr_worker_config_t const * fr_worker_config (fr_worker_t *worker)
 
void fr_worker_debug (fr_worker_t *worker, FILE *fp)
 Print debug information about the worker structure.
 
void fr_worker_exit (fr_worker_t *worker)
 Tidy up a worker on normal exit.
 
int fr_worker_listen_cancel (fr_worker_t *worker, fr_listen_instance_t const *li)
 
static int fr_worker_listen_cancel_self (fr_worker_t *worker, fr_listen_instance_t const *li)
 
static void fr_worker_post_close_event (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 
void fr_worker_post_event (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 Post-event handler.
 
static int fr_worker_pre_close_event (UNUSED fr_time_t now, UNUSED fr_time_delta_t wake, void *uctx)
 
int fr_worker_pre_event (UNUSED fr_time_t now, UNUSED fr_time_delta_t wake, void *uctx)
 Pre-event handler.
 
void fr_worker_shutting_down (fr_worker_t *worker)
 Tell the interpreter of the worker to cancel requests, instead of running them.
 
int fr_worker_stats (fr_worker_t const *worker, int num, uint64_t *stats)
 
static bool is_worker_thread (fr_worker_t const *worker)
 
static char * itoa_internal (TALLOC_CTX *ctx, uint64_t number)
 
static void worker_channel_close (fr_channel_t *ch, UNUSED fr_time_t now, void *uctx)
 The network is closing a channel to us.
 
static void worker_channel_close_ack (fr_worker_t *worker)
 Acknowledge channel close after requests are completed.
 
static void worker_channel_open (fr_channel_t *ch, fr_message_set_t *reply_ms, UNUSED fr_time_t now, void *uctx)
 The network has opened a channel to us.
 
static fr_cmp_ret_t worker_dedup_cmp (void const *one, void const *two)
 Track a request_t in the "dedup" tree.
 
static void worker_listen_cancel_callback (void const *data, NDEBUG_UNUSED size_t data_size, UNUSED fr_time_t now, void *uctx)
 A socket is going away, so clean up any requests which use this socket.
 
static fr_cmp_ret_t worker_listener_cmp (void const *one, void const *two)
 
static void worker_nak (fr_worker_t *worker, fr_channel_data_t *cd, fr_time_t now)
 Send a NAK to the network thread.
 
static uint64_t worker_num_requests (fr_worker_t *worker)
 
static void worker_recv_request (fr_channel_t *ch, fr_channel_data_t *cd, void *uctx)
 Callback which handles a message being received on the worker side.
 
static void worker_request_bootstrap (fr_worker_channel_t *wc, fr_channel_data_t *cd, fr_time_t now)
 
static void worker_request_init (fr_worker_t *worker, request_t *request, fr_time_t now)
 Initialize various request fields needed by the worker.
 
static void worker_request_name_number (request_t *request)
 
static void worker_request_time_tracking_end (fr_worker_t *worker, request_t *request, fr_time_t now)
 
static int worker_request_time_tracking_start (fr_worker_t *worker, request_t *request, fr_time_t now)
 Start time tracking for a request, and mark it as runnable.
 
static void worker_requests_cancel (fr_worker_t *worker, fr_worker_channel_t *ch)
 
static void worker_run_request (fr_worker_t *worker, fr_time_t start)
 Run a request.
 
static fr_cmp_ret_t worker_runnable_cmp (void const *one, void const *two)
 Track a request_t in the "runnable" heap.
 
static void worker_send_reply (fr_worker_t *worker, request_t *request, bool send_reply, fr_time_t now)
 Send a response packet to the network side.
 
static bool worker_sleeping (fr_worker_t *worker)
 Announce we are about to block, then drain every channel one last time.
 
static void worker_stop_request (request_t *request)
 Signal the unlang interpreter that it needs to stop running the request.
 

Variables

fr_cmd_table_t cmd_worker_table []
 
 fr_worker_channel_t
 
static fr_channel_callbacks_t const worker_channel_callbacks
 Channel events the worker handles.
 

Detailed Description

Worker thread functions.

Id
b121b2b60131dc2f64a7c3503c9d98fa7a32dcaa

The "worker" thread is the one responsible for the bulk of the work done when processing a request. Workers are spawned by the scheduler, and create a kqueue (KQ) and control-plane Atomic Queue (AQ) for control-plane communication.

When a network thread discovers that it needs more workers, it asks the scheduler for a KQ/AQ combination. The network thread then creates a channel dedicated to that worker, and sends the channel to the worker in a "new channel" message. The worker receives the channel, and sends an ACK back to the network thread.

The network thread then sends the worker new packets, which the worker receives and processes.

When a packet is decoded, it is put into the "runnable" heap, and also into the timeout sublist. The main loop fr_worker() then pulls new requests off of this heap and runs them. The main event loop checks the head of the timeout sublist, and forcefully terminates any requests which have been running for too long.

If a request is yielded, it is placed onto the yielded list in the worker "tracking" data structure.

Definition in file worker.c.


Data Structure Documentation

◆ fr_worker_listen_t

struct fr_worker_listen_t

Definition at line 132 of file worker.c.

+ Collaboration diagram for fr_worker_listen_t:
Data Fields
fr_dlist_head_t dlist of requests associated with this listener.
fr_listen_instance_t const * listener incoming packets
fr_rb_node_t node in tree of listeners

◆ fr_worker_s

struct fr_worker_s

A worker which takes packets from a master, and processes them.

Definition at line 89 of file worker.c.

+ Collaboration diagram for fr_worker_s:
Data Fields
fr_worker_channel_t * channel list of channels
fr_worker_config_t config external configuration
fr_control_t * control the control plane
fr_time_elapsed_t cpu_time histogram of total CPU time per request
fr_rb_tree_t * dedup de-dup tree
fr_event_list_t * el our event list
bool exiting are we exiting?
unlang_interpret_t * intp Worker's local interpreter.
fr_rb_tree_t * listeners so we can cancel requests when a listener goes away
fr_log_t const * log log destination
fr_log_lvl_t lvl log level
fr_time_delta_t max_request_time maximum time a request can be processed
char const * name name of this worker
uint64_t num_active number of active requests
int num_channels actual number of channels
int num_closing number of channels closing
uint64_t num_naks number of messages which were nak'd
fr_time_delta_t predicted How long we predict a request will take to execute.
fr_heap_t * runnable current runnable requests which we've spent time processing
request_slab_list_t * slab slab allocator for request_t
fr_io_stats_t stats input / output stats
pthread_t thread_id my thread ID
fr_timer_list_t * timeout Track when requests timeout using a dlist.
fr_time_tracking_t tracking how much time the worker has spent doing things.
fr_time_elapsed_t wall_clock histogram of wall clock time per request

Macro Definition Documentation

◆ CHECK_CONFIG

#define CHECK_CONFIG (   _x,
  _min,
  _max 
)
Value:
do { \
if (!worker->config._x) worker->config._x = _min; \
if (worker->config._x < _min) worker->config._x = _min; \
if (worker->config._x > _max) worker->config._x = _max; \
} while (0)
while(1)
Definition acutest.h:1009
static const conf_parser_t config[]
Definition base.c:162

◆ CHECK_CONFIG_TIME_DELTA

#define CHECK_CONFIG_TIME_DELTA (   _x,
  _min,
  _max 
)
Value:
do { \
if (fr_time_delta_lt(worker->config._x, _min)) worker->config._x = _min; \
if (fr_time_delta_gt(worker->config._x, _max)) worker->config._x = _max; \
} while (0)
#define fr_time_delta_lt(_a, _b)
Definition time.h:285
#define fr_time_delta_gt(_a, _b)
Definition time.h:283

◆ LOG_DST

#define LOG_DST   worker->log

Definition at line 52 of file worker.c.

◆ LOG_PREFIX

#define LOG_PREFIX   worker->name

Definition at line 51 of file worker.c.

◆ WORKER_VERIFY

#define WORKER_VERIFY

Definition at line 68 of file worker.c.

Function Documentation

◆ _Atomic()

static _Atomic ( uint64_t  )
static

< the worker that owns this channel slot, so channel callbacks can reach back without threading worker through every layer.

< messages for this channel

< of requests received on this channel

Definition at line 71 of file worker.c.

◆ _worker_request_deinit()

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

Definition at line 723 of file worker.c.

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

◆ _worker_request_detach()

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

Make us responsible for running the request.

Definition at line 1128 of file worker.c.

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

◆ _worker_request_done_detached()

static void _worker_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 1095 of file worker.c.

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

◆ _worker_request_done_external()

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

External request is now complete.

Definition at line 1007 of file worker.c.

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

◆ _worker_request_done_internal()

static void _worker_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 1079 of file worker.c.

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

◆ _worker_request_internal_init()

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

Internal request (i.e.

one generated by the interpreter) is now complete

Definition at line 986 of file worker.c.

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

◆ _worker_request_prioritise()

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

Update a request's priority.

Definition at line 1197 of file worker.c.

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

◆ _worker_request_resume()

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

Interpreter is starting to work on request again.

Definition at line 1180 of file worker.c.

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

◆ _worker_request_runnable()

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

Request is now runnable.

Definition at line 1160 of file worker.c.

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

◆ _worker_request_scheduled()

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

Check if a request is scheduled.

Definition at line 1189 of file worker.c.

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

◆ _worker_request_timeout()

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

Enforce max_request_time.

Run periodically, and tries to clean up requests which were received by the network thread more than max_request_time seconds ago. In the interest of not adding a timer for every packet, the requests are given a 1 second leeway.

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

Definition at line 473 of file worker.c.

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

◆ _worker_request_yield()

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

Interpreter yielded request.

Definition at line 1171 of file worker.c.

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

◆ cmd_stats_worker()

static int cmd_stats_worker ( FILE *  fp,
UNUSED FILE *  fp_err,
void *  ctx,
fr_cmd_info_t const *  info 
)
static

Definition at line 1746 of file worker.c.

+ Here is the call graph for this function:

◆ fr_worker()

void fr_worker ( fr_worker_t *  worker)

The main loop and entry point of the stand-alone worker thread.

Where there is only one thread, the event loop runs fr_worker_pre_event() and fr_worker_post_event() instead, And then fr_worker_post_event() takes care of calling worker_run_request() to actually run the request.

Parameters
[in]workerthe worker data structure to manage

Definition at line 1463 of file worker.c.

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

◆ fr_worker_alloc()

fr_worker_t * fr_worker_alloc ( TALLOC_CTX *  ctx,
fr_event_list_t *  el,
char const *  name,
fr_log_t const *  logger,
fr_log_lvl_t  lvl,
fr_worker_config_t *  config 
)

Create a worker.

Parameters
[in]ctxthe talloc context
[in]namethe name of this worker
[in]elthe event list
[in]loggerthe destination for all logging messages
[in]lvllog level
[in]configvarious configuration parameters
Returns
  • NULL on error
  • fr_worker_t on success

Definition at line 1260 of file worker.c.

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

◆ fr_worker_channel_create()

fr_channel_t * fr_worker_channel_create ( fr_worker_t *  worker,
TALLOC_CTX *  ctx,
fr_control_t *  master,
fr_message_set_t *  reply_ms 
)

Create a channel to the worker.

Called by the master (i.e. network) thread when it needs to create a new channel to a particular worker.

Parameters
[in]workerthe worker
[in]ctxthe context in which the channel will be created
[in]masterthe control plane of the master
[in]reply_msthe message set the worker allocates replies from

Definition at line 1653 of file worker.c.

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

◆ fr_worker_close_event_insert()

int fr_worker_close_event_insert ( fr_worker_t *  worker)

Add events to the loop which will send close ack to the network.

Definition at line 1581 of file worker.c.

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

◆ fr_worker_config()

fr_worker_config_t const * fr_worker_config ( fr_worker_t *  worker)

Definition at line 1741 of file worker.c.

+ Here is the caller graph for this function:

◆ fr_worker_debug()

void fr_worker_debug ( fr_worker_t *  worker,
FILE *  fp 
)

Print debug information about the worker structure.

Parameters
[in]workerthe worker
[in]fpthe file where the debug output is printed.

Definition at line 1625 of file worker.c.

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

◆ fr_worker_exit()

void fr_worker_exit ( fr_worker_t *  worker)

Tidy up a worker on normal exit.

Definition at line 970 of file worker.c.

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

◆ fr_worker_listen_cancel()

int fr_worker_listen_cancel ( fr_worker_t *  worker,
fr_listen_instance_t const *  li 
)

Definition at line 1680 of file worker.c.

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

◆ fr_worker_listen_cancel_self()

static int fr_worker_listen_cancel_self ( fr_worker_t *  worker,
fr_listen_instance_t const *  li 
)
static

Definition at line 311 of file worker.c.

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

◆ fr_worker_post_close_event()

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

Definition at line 1572 of file worker.c.

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

◆ fr_worker_post_event()

void fr_worker_post_event ( UNUSED fr_event_list_t *  el,
UNUSED fr_time_t  now,
void *  uctx 
)

Post-event handler.

This should be run ONLY in single-threaded mode!

Definition at line 1558 of file worker.c.

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

◆ fr_worker_pre_close_event()

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

Definition at line 1565 of file worker.c.

+ Here is the caller graph for this function:

◆ fr_worker_pre_event()

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

Pre-event handler.

This should be run ONLY in single-threaded mode!

Definition at line 1537 of file worker.c.

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

◆ fr_worker_shutting_down()

void fr_worker_shutting_down ( fr_worker_t *  worker)

Tell the interpreter of the worker to cancel requests, instead of running them.

The single threaded scheduler calls this function before it detaches the thread data, so that the requests which the detach cancels do not go into the runnable heap of the worker. A worker thread does the same when the last input channel closes.

Parameters
[in]workerwhich is shutting down.

Definition at line 1602 of file worker.c.

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

◆ fr_worker_stats()

int fr_worker_stats ( fr_worker_t const *  worker,
int  num,
uint64_t *  stats 
)

Definition at line 1724 of file worker.c.

◆ is_worker_thread()

static bool is_worker_thread ( fr_worker_t const *  worker)
inlinestatic

Definition at line 153 of file worker.c.

+ Here is the caller graph for this function:

◆ itoa_internal()

static char * itoa_internal ( TALLOC_CTX *  ctx,
uint64_t  number 
)
static

Definition at line 669 of file worker.c.

+ Here is the caller graph for this function:

◆ worker_channel_close()

static void worker_channel_close ( fr_channel_t *  ch,
UNUSED fr_time_t  now,
void *  uctx 
)
static

The network is closing a channel to us.

Parameters
[in]chthe channel
[in]nowthe current time
[in]uctxthe worker

Definition at line 247 of file worker.c.

+ Here is the call graph for this function:

◆ worker_channel_close_ack()

static void worker_channel_close_ack ( fr_worker_t *  worker)
inlinestatic

Acknowledge channel close after requests are completed.

When the channel close is acknowledged, the network frees the channel which then causes issues with any requests still referencing the channel.

Definition at line 1439 of file worker.c.

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

◆ worker_channel_open()

static void worker_channel_open ( fr_channel_t *  ch,
fr_message_set_t *  reply_ms,
UNUSED fr_time_t  now,
void *  uctx 
)
static

The network has opened a channel to us.

Parameters
[in]chthe new channel
[in]reply_msthe message set for replies on this channel
[in]nowthe current time
[in]uctxthe worker

Definition at line 200 of file worker.c.

+ Here is the call graph for this function:

◆ worker_dedup_cmp()

static fr_cmp_ret_t worker_dedup_cmp ( void const *  one,
void const *  two 
)
static

Track a request_t in the "dedup" tree.

Definition at line 956 of file worker.c.

+ Here is the caller graph for this function:

◆ worker_listen_cancel_callback()

static void worker_listen_cancel_callback ( void const *  data,
NDEBUG_UNUSED size_t  data_size,
UNUSED fr_time_t  now,
void *  uctx 
)
static

A socket is going away, so clean up any requests which use this socket.

Parameters
[in]datathe message
[in]data_sizesize of the data
[in]nowthe current time
[in]uctxthe worker

Definition at line 338 of file worker.c.

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

◆ worker_listener_cmp()

static fr_cmp_ret_t worker_listener_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 145 of file worker.c.

+ Here is the caller graph for this function:

◆ worker_nak()

static void worker_nak ( fr_worker_t *  worker,
fr_channel_data_t *  cd,
fr_time_t  now 
)
static

Send a NAK to the network thread.

The network thread believes that a worker is running a request until that request has been NAK'd. We typically NAK requests when they've been hanging around in the worker's backlog too long, or there was an error executing the request.

Parameters
[in]workerthe worker
[in]cdthe message to NAK
[in]nowwhen the message is NAKd

Definition at line 360 of file worker.c.

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

◆ worker_num_requests()

static uint64_t worker_num_requests ( fr_worker_t *  worker)
inlinestatic

Definition at line 718 of file worker.c.

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

◆ worker_recv_request()

static void worker_recv_request ( fr_channel_t *  ch,
fr_channel_data_t *  cd,
void *  uctx 
)
static

Callback which handles a message being received on the worker side.

Parameters
[in]chthe channel to drain
[in]cdthe message (if any) to start with
[in]uctxthe worker channel slot the message came in on

Definition at line 167 of file worker.c.

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

◆ worker_request_bootstrap()

static void worker_request_bootstrap ( fr_worker_channel_t *  wc,
fr_channel_data_t *  cd,
fr_time_t  now 
)
static

Definition at line 728 of file worker.c.

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

◆ worker_request_init()

static void worker_request_init ( fr_worker_t *  worker,
request_t *  request,
fr_time_t  now 
)
inlinestatic

Initialize various request fields needed by the worker.

Definition at line 692 of file worker.c.

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

◆ worker_request_name_number()

static void worker_request_name_number ( request_t *  request)
inlinestatic

Definition at line 710 of file worker.c.

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

◆ worker_request_time_tracking_end()

static void worker_request_time_tracking_end ( fr_worker_t *  worker,
request_t *  request,
fr_time_t  now 
)
static

Definition at line 523 of file worker.c.

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

◆ worker_request_time_tracking_start()

static int worker_request_time_tracking_start ( fr_worker_t *  worker,
request_t *  request,
fr_time_t  now 
)
static

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

Definition at line 493 of file worker.c.

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

◆ worker_requests_cancel()

static void worker_requests_cancel ( fr_worker_t *  worker,
fr_worker_channel_t *  ch 
)
static

Definition at line 178 of file worker.c.

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

◆ worker_run_request()

static void worker_run_request ( fr_worker_t *  worker,
fr_time_t  start 
)
inlinestatic

Run a request.

Until it either yields, or is done.

This function is also responsible for sending replies, and cleaning up the request.

Parameters
[in]workerthe worker
[in]startthe current time

Definition at line 1220 of file worker.c.

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

◆ worker_runnable_cmp()

static fr_cmp_ret_t worker_runnable_cmp ( void const *  one,
void const *  two 
)
static

Track a request_t in the "runnable" heap.

Higher priorities take precedence, followed by lower sequence numbers

Definition at line 930 of file worker.c.

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

◆ worker_send_reply()

static void worker_send_reply ( fr_worker_t *  worker,
request_t *  request,
bool  send_reply,
fr_time_t  now 
)
static

Send a response packet to the network side.

Parameters
[in]workerThis worker.
[in]requestwe're sending a reply for.
[in]send_replywhether the network side sends a reply
[in]nowThe current time

Definition at line 540 of file worker.c.

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

◆ worker_sleeping()

static bool worker_sleeping ( fr_worker_t *  worker)
inlinestatic

Announce we are about to block, then drain every channel one last time.

See fr_control_sleeping() for the ordering this relies on.

Returns
  • true if a channel had messages, so the caller must not block.
  • false if every channel was empty.

Definition at line 1406 of file worker.c.

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

◆ worker_stop_request()

static void worker_stop_request ( request_t *  request)
static

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

Signalling is a synchronous operation. Whatever I/O requests the request is currently performing are signalled to be cancelled. Depending on the specific back end, the actual cancellation may be asynchronously handled by the trunk code.

Modules and unlang keywords explicitly register signal handlers to deal with their yield points being cancelled/interrupted via this function.

Following this, the request still needs to be run through the interpreter to tidy up and potentially run a finally section.

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

Definition at line 454 of file worker.c.

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

Variable Documentation

◆ cmd_worker_table

fr_cmd_table_t cmd_worker_table[]
Initial value:
= {
{
.parent = "stats",
.name = "worker",
.help = "Statistics for workers threads.",
.read_only = true
},
{
.parent = "stats worker",
.add_name = true,
.name = "self",
.syntax = "[(count|cpu)]",
.help = "Show statistics for a specific worker thread.",
.read_only = true
},
}
#define CMD_TABLE_END
Definition command.h:62
static int cmd_stats_worker(FILE *fp, UNUSED FILE *fp_err, void *ctx, fr_cmd_info_t const *info)
Definition worker.c:1746

Definition at line 1784 of file worker.c.

◆ fr_worker_channel_t

fr_worker_channel_t

Definition at line 84 of file worker.c.

◆ worker_channel_callbacks

fr_channel_callbacks_t const worker_channel_callbacks
static
Initial value:
= {
}
static void worker_channel_open(fr_channel_t *ch, fr_message_set_t *reply_ms, UNUSED fr_time_t now, void *uctx)
The network has opened a channel to us.
Definition worker.c:200
static void worker_channel_close(fr_channel_t *ch, UNUSED fr_time_t now, void *uctx)
The network is closing a channel to us.
Definition worker.c:247

Channel events the worker handles.

Definition at line 306 of file worker.c.