The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
channel_test.c File Reference
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/io/channel.h>
#include <freeradius-devel/io/control.h>
#include <freeradius-devel/io/message.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/rand.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/talloc.h>
#include <freeradius-devel/util/stdatomic.h>
#include <pthread.h>
+ Include dependency graph for channel_test.c:

Go to the source code of this file.

Data Structures

struct  payload_t
 What travels in each request, and is echoed back in its reply. More...
 
struct  req_channel_t
 A requestor's view of one channel. More...
 
struct  requestor_s
 
struct  resp_channel_t
 A responder's view of one channel. More...
 
struct  responder_s
 

Macros

#define MPRINT1   if (debug_lvl) printf
 
#define MPRINT2   if (debug_lvl > 1) printf
 
#define PAYLOAD_SIZE   (sizeof(payload_t))
 

Typedefs

typedef struct requestor_s requestor_t
 
typedef struct responder_s responder_t
 

Functions

static _Atomic (uint64_t)
 
static void dump_state (void)
 
int main (int argc, char *argv[])
 
static void requestor_closed (fr_channel_t *ch, UNUSED fr_time_t now, void *uctx)
 
static void requestor_recv_reply (fr_channel_t *ch, fr_channel_data_t *cd, UNUSED void *uctx)
 
static void * requestor_thread (void *arg)
 
static void responder_close (fr_channel_t *ch, UNUSED fr_time_t now, void *uctx)
 
static void responder_open (fr_channel_t *ch, fr_message_set_t *reply_ms, UNUSED fr_time_t now, void *uctx)
 
static void responder_recv_request (fr_channel_t *ch, fr_channel_data_t *cd, void *uctx)
 
static void responder_run (responder_t *w)
 Reply to everything pending at the start of this pass.
 
static bool responder_sleeping (responder_t *w)
 The responder half of the handshake, as fr_worker() does it.
 
static void * responder_thread (void *arg)
 
static void spin (uint32_t max_usec)
 Burn a random amount of time without a syscall.
 
static void * watchdog_thread (UNUSED void *arg)
 

Variables

static bool broken = false
 
static int debug_lvl = 0
 
static uint64_t max_messages = 100000
 
static uint64_t max_outstanding = 64
 
static uint32_t max_pause_usec = 20
 
static uint32_t max_work_usec = 2
 
static size_t num_requestors = 2
 
static size_t num_responders = 4
 
static fr_channel_callbacks_t const requestor_callbacks
 
static requestor_t * requestors
 
static fr_channel_callbacks_t const responder_callbacks
 
static responder_t * responders
 
static size_t set_messages = 0
 message set size override, 0 for automatic.
 
static unsigned int watchdog_secs = 5
 

Data Structure Documentation

◆ payload_t

struct payload_t

What travels in each request, and is echoed back in its reply.

Definition at line 53 of file channel_test.c.

Data Fields
uint64_t requestor
uint64_t responder
uint64_t seq

◆ req_channel_t

struct req_channel_t

A requestor's view of one channel.

Definition at line 66 of file channel_test.c.

+ Collaboration diagram for req_channel_t:
Data Fields
fr_channel_t * ch
bool closed
bool closing
uint64_t last_seq of the last reply, replies must arrive in order.
uint64_t outstanding
uint64_t replied
fr_message_set_t * reply_ms replies are allocated from this by the responder.
requestor_t * requestor
size_t responder index of the responder at the other end.
uint64_t sent

◆ requestor_s

struct requestor_s

Definition at line 81 of file channel_test.c.

+ Collaboration diagram for requestor_s:
Data Fields
req_channel_t * channel one per responder.
fr_control_t * control
fr_event_list_t * el
size_t id
fr_message_set_t * ms requests are allocated from this.
size_t num_closed

◆ resp_channel_t

struct resp_channel_t

A responder's view of one channel.

Definition at line 93 of file channel_test.c.

+ Collaboration diagram for resp_channel_t:
Data Fields
fr_channel_t * ch
fr_message_set_t * reply_ms

◆ responder_s

struct responder_s

Definition at line 98 of file channel_test.c.

+ Collaboration diagram for responder_s:
Data Fields
resp_channel_t * channel one slot per requestor.
fr_control_t * control
fr_event_list_t * el
size_t id
size_t num_channels
size_t num_closed
fr_channel_data_t ** pending requests received but not yet replied to.
size_t pending_head
size_t pending_num
size_t pending_size
uint64_t received
uint64_t rescued final drains which found work, i.e. skipped signals we caught.
bool running
uint64_t sleeps times we blocked.

Macro Definition Documentation

◆ MPRINT1

#define MPRINT1   if (debug_lvl) printf

Definition at line 48 of file channel_test.c.

◆ MPRINT2

#define MPRINT2   if (debug_lvl > 1) printf

Definition at line 49 of file channel_test.c.

◆ PAYLOAD_SIZE

#define PAYLOAD_SIZE   (sizeof(payload_t))

Definition at line 59 of file channel_test.c.

Typedef Documentation

◆ requestor_t

typedef struct requestor_s requestor_t

Definition at line 61 of file channel_test.c.

◆ responder_t

typedef struct responder_s responder_t

Definition at line 62 of file channel_test.c.

Function Documentation

◆ _Atomic()

static _Atomic ( uint64_t  )
static

Definition at line 132 of file channel_test.c.

◆ dump_state()

static void dump_state ( void  )
static

Definition at line 482 of file channel_test.c.

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

◆ main()

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

Definition at line 544 of file channel_test.c.

+ Here is the call graph for this function:

◆ requestor_closed()

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

Definition at line 196 of file channel_test.c.

+ Here is the call graph for this function:

◆ requestor_recv_reply()

static void requestor_recv_reply ( fr_channel_t *  ch,
fr_channel_data_t *  cd,
UNUSED void *  uctx 
)
static

Definition at line 173 of file channel_test.c.

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

◆ requestor_thread()

static void * requestor_thread ( void *  arg)
static

Definition at line 211 of file channel_test.c.

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

◆ responder_close()

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

Definition at line 344 of file channel_test.c.

+ Here is the call graph for this function:

◆ responder_open()

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

Definition at line 323 of file channel_test.c.

+ Here is the call graph for this function:

◆ responder_recv_request()

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

Definition at line 309 of file channel_test.c.

+ Here is the caller graph for this function:

◆ responder_run()

static void responder_run ( responder_t *  w)
static

Reply to everything pending at the start of this pass.

Replies made during the pass may queue more requests, which wait for the next pass, as they would in the worker.

Definition at line 404 of file channel_test.c.

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

◆ responder_sleeping()

static bool responder_sleeping ( responder_t *  w)
static

The responder half of the handshake, as fr_worker() does it.

Returns
true if the final drain found work, so the caller must not block.

Definition at line 377 of file channel_test.c.

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

◆ responder_thread()

static void * responder_thread ( void *  arg)
static

Definition at line 444 of file channel_test.c.

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

◆ spin()

static void spin ( uint32_t  max_usec)
static

Burn a random amount of time without a syscall.

Definition at line 157 of file channel_test.c.

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

◆ watchdog_thread()

static void * watchdog_thread ( UNUSED void *  arg)
static

Definition at line 507 of file channel_test.c.

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

Variable Documentation

◆ broken

bool broken = false
static

Definition at line 126 of file channel_test.c.

◆ debug_lvl

int debug_lvl = 0
static

Definition at line 118 of file channel_test.c.

◆ max_messages

uint64_t max_messages = 100000
static

Definition at line 121 of file channel_test.c.

◆ max_outstanding

uint64_t max_outstanding = 64
static

Definition at line 122 of file channel_test.c.

◆ max_pause_usec

uint32_t max_pause_usec = 20
static

Definition at line 124 of file channel_test.c.

◆ max_work_usec

uint32_t max_work_usec = 2
static

Definition at line 123 of file channel_test.c.

◆ num_requestors

size_t num_requestors = 2
static

Definition at line 119 of file channel_test.c.

◆ num_responders

size_t num_responders = 4
static

Definition at line 120 of file channel_test.c.

◆ requestor_callbacks

fr_channel_callbacks_t const requestor_callbacks
static
Initial value:
= {
.closed = requestor_closed
}
static void requestor_closed(fr_channel_t *ch, UNUSED fr_time_t now, void *uctx)

Definition at line 207 of file channel_test.c.

◆ requestors

requestor_t* requestors
static

Definition at line 129 of file channel_test.c.

◆ responder_callbacks

fr_channel_callbacks_t const responder_callbacks
static
Initial value:
= {
.open = responder_open,
.close = responder_close
}
static void responder_open(fr_channel_t *ch, fr_message_set_t *reply_ms, UNUSED fr_time_t now, void *uctx)
static void responder_close(fr_channel_t *ch, UNUSED fr_time_t now, void *uctx)

Definition at line 368 of file channel_test.c.

◆ responders

responder_t* responders
static

Definition at line 130 of file channel_test.c.

◆ set_messages

size_t set_messages = 0
static

message set size override, 0 for automatic.

Definition at line 127 of file channel_test.c.

◆ watchdog_secs

unsigned int watchdog_secs = 5
static

Definition at line 125 of file channel_test.c.