The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions | Variables
atomic_queue_test.c File Reference
#include <freeradius-devel/io/atomic_queue.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/strerror.h>
#include <string.h>
#include <sys/time.h>
+ Include dependency graph for atomic_queue_test.c:

Go to the source code of this file.

Macros

#define OFFSET   (1024)
 

Typedefs

typedef void(* queue_test_t) (TALLOC_CTX *ctx, int size)
 
typedef struct request_s request_t
 

Enumerations

enum  queue_type_t : uint8_t {
  QUEUE_TYPE_TALLOC = 0 ,
  QUEUE_TYPE_MALLOC ,
  QUEUE_TYPE_MMAP ,
  QUEUE_TYPE_MAX
}
 Which allocator the queue under test comes from. More...
 

Functions

int main (int argc, char *argv[])
 
static void queue_exercise (fr_atomic_queue_t *aq, int size)
 Fill and drain with the many-producer functions, then the single-producer ones.
 
static void queue_exercise_flavour (fr_atomic_queue_t *aq, int size, bool(*push)(fr_atomic_queue_t *, void const *), bool(*pop)(fr_atomic_queue_t *, void *))
 Fill the queue to capacity, check it refuses one more, then drain it.
 
void request_verify (UNUSED char const *file, UNUSED int line, UNUSED request_t *request)
 
static void test_malloc (TALLOC_CTX *ctx, int size)
 Queue allocated outside talloc, but owned by a talloc context.
 
static void test_mmap (TALLOC_CTX *ctx, int size)
 Queue in a shared memory mapping, owned by a talloc handle.
 
static void test_talloc (TALLOC_CTX *ctx, int size)
 Queue allocated inside the talloc hierarchy.
 
static NEVER_RETURNS void usage (void)
 

Variables

static int debug_lvl = 0
 
static queue_test_t const queue_tests [QUEUE_TYPE_MAX]
 
static fr_table_num_sorted_t const queue_type_table []
 
static size_t queue_type_table_len = NUM_ELEMENTS(queue_type_table)
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET   (1024)

Definition at line 36 of file atomic_queue_test.c.

Typedef Documentation

◆ queue_test_t

typedef void(* queue_test_t) (TALLOC_CTX *ctx, int size)

Definition at line 318 of file atomic_queue_test.c.

◆ request_t

typedef struct request_s request_t

Definition at line 58 of file atomic_queue_test.c.

Enumeration Type Documentation

◆ queue_type_t

Which allocator the queue under test comes from.

Enumerator
QUEUE_TYPE_TALLOC 

fr_atomic_queue_talloc, queue lives in the talloc hierarchy.

QUEUE_TYPE_MALLOC 

fr_atomic_queue_malloc, raw queue owned by a talloc handle.

QUEUE_TYPE_MMAP 

fr_atomic_queue_mmap, shared memory queue owned by a talloc handle.

QUEUE_TYPE_MAX 

Definition at line 42 of file atomic_queue_test.c.

Function Documentation

◆ main()

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

Definition at line 326 of file atomic_queue_test.c.

+ Here is the call graph for this function:

◆ queue_exercise()

static void queue_exercise ( fr_atomic_queue_t *  aq,
int  size 
)
static

Fill and drain with the many-producer functions, then the single-producer ones.

Definition at line 179 of file atomic_queue_test.c.

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

◆ queue_exercise_flavour()

static void queue_exercise_flavour ( fr_atomic_queue_t *  aq,
int  size,
bool(*)(fr_atomic_queue_t *, void const *)  push,
bool(*)(fr_atomic_queue_t *, void *)  pop 
)
static

Fill the queue to capacity, check it refuses one more, then drain it.

Exits the process on the first wrong answer.

Definition at line 81 of file atomic_queue_test.c.

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

◆ request_verify()

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

Definition at line 61 of file atomic_queue_test.c.

+ Here is the caller graph for this function:

◆ test_malloc()

static void test_malloc ( TALLOC_CTX *  ctx,
int  size 
)
static

Queue allocated outside talloc, but owned by a talloc context.

The only talloc'd block is the owner handle, so the context holds exactly one child, and freeing the context releases the raw queue through the handle.

Definition at line 207 of file atomic_queue_test.c.

+ Here is the call graph for this function:

◆ test_mmap()

static void test_mmap ( TALLOC_CTX *  ctx,
int  size 
)
static

Queue in a shared memory mapping, owned by a talloc handle.

As test_malloc for the creator. Then a second queue is attached to the creator's descriptor, as another process would, and elements pushed through one are popped from the other.

Definition at line 235 of file atomic_queue_test.c.

+ Here is the call graph for this function:

◆ test_talloc()

static void test_talloc ( TALLOC_CTX *  ctx,
int  size 
)
static

Queue allocated inside the talloc hierarchy.

Definition at line 187 of file atomic_queue_test.c.

+ Here is the call graph for this function:

◆ usage()

static NEVER_RETURNS void usage ( void  )
static

Definition at line 67 of file atomic_queue_test.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ debug_lvl

int debug_lvl = 0
static

Definition at line 38 of file atomic_queue_test.c.

◆ queue_tests

queue_test_t const queue_tests[QUEUE_TYPE_MAX]
static
Initial value:
= {
}
static void test_malloc(TALLOC_CTX *ctx, int size)
Queue allocated outside talloc, but owned by a talloc context.
static void test_mmap(TALLOC_CTX *ctx, int size)
Queue in a shared memory mapping, owned by a talloc handle.
static void test_talloc(TALLOC_CTX *ctx, int size)
Queue allocated inside the talloc hierarchy.
@ QUEUE_TYPE_MALLOC
fr_atomic_queue_malloc, raw queue owned by a talloc handle.
@ QUEUE_TYPE_MMAP
fr_atomic_queue_mmap, shared memory queue owned by a talloc handle.
@ QUEUE_TYPE_TALLOC
fr_atomic_queue_talloc, queue lives in the talloc hierarchy.

Definition at line 320 of file atomic_queue_test.c.

◆ queue_type_table

fr_table_num_sorted_t const queue_type_table[]
static
Initial value:
= {
{ L("malloc"), QUEUE_TYPE_MALLOC },
{ L("mmap"), QUEUE_TYPE_MMAP },
{ L("talloc"), QUEUE_TYPE_TALLOC }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:245

Definition at line 49 of file atomic_queue_test.c.

◆ queue_type_table_len

size_t queue_type_table_len = NUM_ELEMENTS(queue_type_table)
static

Definition at line 54 of file atomic_queue_test.c.