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

Functions and data structures for worker threads. More...

#include <freeradius-devel/io/base.h>
#include <freeradius-devel/server/command.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/heap.h>
#include <freeradius-devel/util/log.h>
#include <freeradius-devel/util/slab.h>
#include <freeradius-devel/util/talloc.h>
#include <pthread.h>
#include <freeradius-devel/server/module.h>
+ Include dependency graph for worker.h:

Go to the source code of this file.

Data Structures

struct  fr_worker_config_t
 

Typedefs

typedef enum fr_worker_control_event_t fr_worker_control_event_t
 Events for a worker's own control messages, in the FR_CONTROL_EVENTSET_WORKER event set.
 
typedef struct fr_worker_s fr_worker_t
 A data structure to track the worker.
 

Enumerations

enum  fr_worker_control_event_t : uint16_t { FR_WORKER_CONTROL_LISTEN_DEAD = 0 }
 Events for a worker's own control messages, in the FR_CONTROL_EVENTSET_WORKER event set. More...
 

Functions

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)
 
void fr_worker_post_event (fr_event_list_t *el, fr_time_t now, void *uctx)
 
int fr_worker_pre_event (fr_time_t now, fr_time_delta_t wake, void *uctx)
 
int fr_worker_request_timeout_set (fr_worker_t *worker, request_t *request, fr_time_delta_t timeout)
 
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)
 
int fr_worker_subrequest_add (request_t *request)
 

Variables

fr_cmd_table_t cmd_worker_table []
 

Detailed Description

Functions and data structures for worker threads.

Id
ddf0f29e17efa34776a213ded041367f0b70c99b

Definition in file worker.h.


Data Structure Documentation

◆ fr_worker_config_t

struct fr_worker_config_t

Definition at line 65 of file worker.h.

+ Collaboration diagram for fr_worker_config_t:
Data Fields
int max_channels maximum number of channels
fr_time_delta_t max_request_time maximum time a request can be processed
int max_requests max requests this worker will handle
int message_set_size default start number of messages
fr_slab_config_t reuse slab allocator configuration
int ring_buffer_size default start size for the ring buffers

Typedef Documentation

◆ fr_worker_control_event_t

Events for a worker's own control messages, in the FR_CONTROL_EVENTSET_WORKER event set.

◆ fr_worker_t

typedef struct fr_worker_s fr_worker_t

A data structure to track the worker.

Once spawned, workers exist until they choose to exit.

Definition at line 44 of file worker.h.

Enumeration Type Documentation

◆ fr_worker_control_event_t

Events for a worker's own control messages, in the FR_CONTROL_EVENTSET_WORKER event set.

Enumerator
FR_WORKER_CONTROL_LISTEN_DEAD 

A listener has been closed.

Definition at line 35 of file worker.h.

Function Documentation

◆ 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_post_event()

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

◆ fr_worker_pre_event()

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

◆ fr_worker_request_timeout_set()

int fr_worker_request_timeout_set ( fr_worker_t *  worker,
request_t *  request,
fr_time_delta_t  timeout 
)

◆ 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.

◆ fr_worker_subrequest_add()

int fr_worker_subrequest_add ( request_t *  request)

Variable Documentation

◆ cmd_worker_table

fr_cmd_table_t cmd_worker_table[]
extern

Definition at line 1784 of file worker.c.