The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | 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
 

Macros

#define FR_CONTROL_ID_DIRECTORY   (4)
 
#define FR_CONTROL_ID_INJECT   (5)
 
#define FR_CONTROL_ID_LISTEN   (2)
 
#define FR_CONTROL_ID_LISTEN_DEAD   (6)
 
#define FR_CONTROL_ID_WORKER   (3)
 

Typedefs

typedef struct fr_worker_s fr_worker_t
 A data structure to track the worker.
 

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, void *uctx))
 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_destroy (fr_worker_t *worker)
 Destroy a worker.
 
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_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)
 
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
618f73a529d348d279489a40a7035d08bb7ae0f6

Definition in file worker.h.


Data Structure Documentation

◆ fr_worker_config_t

struct fr_worker_config_t

Definition at line 68 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

Macro Definition Documentation

◆ FR_CONTROL_ID_DIRECTORY

#define FR_CONTROL_ID_DIRECTORY   (4)

Definition at line 38 of file worker.h.

◆ FR_CONTROL_ID_INJECT

#define FR_CONTROL_ID_INJECT   (5)

Definition at line 39 of file worker.h.

◆ FR_CONTROL_ID_LISTEN

#define FR_CONTROL_ID_LISTEN   (2)

Definition at line 36 of file worker.h.

◆ FR_CONTROL_ID_LISTEN_DEAD

#define FR_CONTROL_ID_LISTEN_DEAD   (6)

Definition at line 40 of file worker.h.

◆ FR_CONTROL_ID_WORKER

#define FR_CONTROL_ID_WORKER   (3)

Definition at line 37 of file worker.h.

Typedef Documentation

◆ 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 47 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 1578 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 1406 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,
void *  uctx 
)

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]uctxto include in the channel open message

Definition at line 1728 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 1682 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 1820 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 1700 of file worker.c.

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

◆ fr_worker_destroy()

void fr_worker_destroy ( fr_worker_t *  worker)

Destroy a worker.

The input channels are signaled, and local messages are cleaned up.

This should be called to EXPLICITLY destroy a worker, when some fatal error has occurred on the worker side, and we need to destroy it.

We signal all pending requests in the backlog to stop, and tell the network side that it should not send us any more requests.

Parameters
[in]workerthe worker to destroy.

Definition at line 1061 of file worker.c.

+ Here is the call 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 1120 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_t const *  li 
)

Definition at line 1754 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_stats()

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

Definition at line 1803 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 1863 of file worker.c.