The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions | Variables
worker_test.c File Reference
#include <freeradius-devel/io/control.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/worker.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/talloc.h>
#include <pthread.h>
#include <signal.h>
#include <sys/event.h>
+ Include dependency graph for worker_test.c:

Go to the source code of this file.

Data Structures

struct  fr_schedule_worker_t
 Scheduler specific information for worker threads. More...
 

Macros

#define MAX_CONTROL_PLANE   (1024)
 
#define MAX_KEVENTS   (10)
 
#define MAX_MESSAGES   (2048)
 
#define MAX_WORKERS   (1024)
 
#define MPRINT1   if (debug_lvl) printf
 
#define MPRINT2   if (debug_lvl > 1) printf
 

Typedefs

typedef struct request_s request_t
 

Functions

int main (int argc, char *argv[])
 
static void master_process (void)
 
request_trequest_alloc (UNUSED TALLOC_CTX *ctx, UNUSED request_init_args_t const *args)
 
void request_verify (UNUSED char const *file, UNUSED int line, UNUSED request_t const *request)
 
static void sig_ignore (int sig)
 
static int test_decode (UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
 
static ssize_t test_encode (void const *instance, request_t *request, uint8_t *const data, size_t data_len)
 
static size_t test_nak (UNUSED void const *instance, void *packet_ctx, uint8_t *const packet, size_t packet_len, uint8_t *reply, UNUSED size_t reply_len)
 
static rlm_rcode_t test_process (UNUSED void const *inst, request_t *request, fr_io_action_t action)
 
static NEVER_RETURNS void usage (void)
 
static void * worker_thread (void *arg)
 

Variables

static fr_app_io_t app_io
 
static fr_atomic_queue_taq_master
 
static fr_control_tcontrol_master
 
static int debug_lvl = 0
 
static int kq_master
 
static int max_control_plane = 0
 
static int max_messages = 10
 
static int max_outstanding = 1
 
static int num_workers = 1
 
static bool quiet = false
 
static bool touch_memory = false
 
static fr_schedule_worker_t workers [MAX_WORKERS]
 

Data Structure Documentation

◆ fr_schedule_worker_t

struct fr_schedule_worker_t

Scheduler specific information for worker threads.

Wraps a fr_worker_t, tracking additional information that the scheduler uses.

Definition at line 83 of file schedule.c.

+ Collaboration diagram for fr_schedule_worker_t:
Data Fields
fr_channel_t * ch channel for communicating with the worker
fr_time_t cpu_time how much CPU time this worker has used
TALLOC_CTX * ctx our allocation ctx
fr_event_list_t * el our event list
fr_dlist_t entry our entry into the linked list of workers
unsigned int id a unique ID

ID of the worker 0..N.

int id ID of the worker 0..N.
pthread_t pthread_id the thread of this worker

pthread ID of the worker

fr_schedule_t * sc the scheduler we are running under
fr_schedule_child_status_t status status of the worker
int uses how many network threads are using it
fr_worker_t * worker the worker data structure

pointer to the worker

Macro Definition Documentation

◆ MAX_CONTROL_PLANE

#define MAX_CONTROL_PLANE   (1024)

Definition at line 42 of file worker_test.c.

◆ MAX_KEVENTS

#define MAX_KEVENTS   (10)

Definition at line 43 of file worker_test.c.

◆ MAX_MESSAGES

#define MAX_MESSAGES   (2048)

Definition at line 41 of file worker_test.c.

◆ MAX_WORKERS

#define MAX_WORKERS   (1024)

Definition at line 44 of file worker_test.c.

◆ MPRINT1

#define MPRINT1   if (debug_lvl) printf

Definition at line 46 of file worker_test.c.

◆ MPRINT2

#define MPRINT2   if (debug_lvl > 1) printf

Definition at line 47 of file worker_test.c.

Typedef Documentation

◆ request_t

typedef struct request_s request_t

Definition at line 66 of file worker_test.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 476 of file worker_test.c.

+ Here is the call graph for this function:

◆ master_process()

static void master_process ( void  )
static

Definition at line 188 of file worker_test.c.

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

◆ request_alloc()

request_t* request_alloc ( UNUSED TALLOC_CTX *  ctx,
UNUSED request_init_args_t const *  args 
)

Definition at line 71 of file worker_test.c.

◆ request_verify()

void request_verify ( UNUSED char const *  file,
UNUSED int  line,
UNUSED request_t const *  request 
)

Definition at line 76 of file worker_test.c.

◆ sig_ignore()

static void sig_ignore ( int  sig)
static

Definition at line 471 of file worker_test.c.

+ Here is the caller graph for this function:

◆ test_decode()

static int test_decode ( UNUSED void const *  instance,
request_t request,
uint8_t *const  data,
size_t  data_len 
)
static

Definition at line 102 of file worker_test.c.

+ Here is the call graph for this function:

◆ test_encode()

static ssize_t test_encode ( void const *  instance,
request_t request,
uint8_t *const  data,
size_t  data_len 
)
static

Definition at line 119 of file worker_test.c.

◆ test_nak()

static size_t test_nak ( UNUSED void const *  instance,
void *  packet_ctx,
uint8_t *const  packet,
size_t  packet_len,
uint8_t reply,
UNUSED size_t  reply_len 
)
static

Definition at line 127 of file worker_test.c.

◆ test_process()

static rlm_rcode_t test_process ( UNUSED void const *  inst,
request_t request,
fr_io_action_t  action 
)
static

Definition at line 96 of file worker_test.c.

+ Here is the caller graph for this function:

◆ usage()

static NEVER_RETURNS void usage ( void  )
static

Definition at line 82 of file worker_test.c.

+ Here is the caller graph for this function:

◆ worker_thread()

static void* worker_thread ( void *  arg)
static

Definition at line 150 of file worker_test.c.

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

Variable Documentation

◆ app_io

fr_app_io_t app_io
static
Initial value:
= {
.name = "worker-test",
.default_message_size = 4096,
.nak = test_nak,
.encode = test_encode,
.decode = test_decode
}
static int test_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Definition: worker_test.c:102
static size_t test_nak(UNUSED void const *instance, void *packet_ctx, uint8_t *const packet, size_t packet_len, uint8_t *reply, UNUSED size_t reply_len)
Definition: worker_test.c:127
static ssize_t test_encode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Definition: worker_test.c:119

Definition at line 142 of file worker_test.c.

◆ aq_master

fr_atomic_queue_t* aq_master
static

Definition at line 58 of file worker_test.c.

◆ control_master

fr_control_t* control_master
static

Definition at line 59 of file worker_test.c.

◆ debug_lvl

int debug_lvl = 0
static

Definition at line 56 of file worker_test.c.

◆ kq_master

int kq_master
static

Definition at line 57 of file worker_test.c.

◆ max_control_plane

int max_control_plane = 0
static

Definition at line 61 of file worker_test.c.

◆ max_messages

int max_messages = 10
static

Definition at line 60 of file worker_test.c.

◆ max_outstanding

int max_outstanding = 1
static

Definition at line 62 of file worker_test.c.

◆ num_workers

int num_workers = 1
static

Definition at line 64 of file worker_test.c.

◆ quiet

bool quiet = false
static

Definition at line 65 of file worker_test.c.

◆ touch_memory

bool touch_memory = false
static

Definition at line 63 of file worker_test.c.

◆ workers

Definition at line 66 of file worker_test.c.