![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
#include <freeradius-devel/server/base.h>#include <freeradius-devel/io/control.h>#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/rand.h>#include <freeradius-devel/util/syserror.h>#include <freeradius-devel/util/talloc.h>#include <freeradius-devel/util/semaphore.h>#include <sys/event.h>#include <sys/socket.h>#include <pthread.h>#include <sched.h>
Include dependency graph for control_test.c:Go to the source code of this file.
Data Structures | |
| struct | master_ctx_t |
| struct | worker_args_t |
Macros | |
| #define | CONTROL_MAGIC 0xabcd6809 |
| #define | MEM(x) do { if (!(x)) { fprintf(stderr, "%s[%d] OUT OF MEMORY\n", __FILE__, __LINE__); _exit(EXIT_FAILURE); } } while (0) |
| #define | MPRINT1 if (debug_lvl) printf |
| #define | MPRINT2 if (debug_lvl >= 2) printf |
| #define | MPRINT3 if (debug_lvl >= 3) printf |
Typedefs | |
| typedef enum control_test_event_t | control_test_event_t |
| Events on the test's control planes. | |
| typedef enum control_test_socket_event_t | control_test_socket_event_t |
| Events whose messages carry a socket, numbered separately from those above. | |
Enumerations | |
| enum | control_test_event_t : uint16_t { CONTROL_TEST_MESSAGE = 0 } |
| Events on the test's control planes. More... | |
| enum | control_test_socket_event_t : uint16_t { CONTROL_TEST_SOCKET = 0 } |
| Events whose messages carry a socket, numbered separately from those above. More... | |
Functions | |
| static | _Atomic (size_t) |
| static void * | control_master (void *arg) |
| static void * | control_worker (void *arg) |
| int | main (int argc, char *argv[]) |
| static void | recv_control_callback (void const *data, size_t data_size, UNUSED fr_time_t now, void *uctx) |
| static void | recv_socket_callback (int sock, UNUSED fr_time_t now, void *uctx) |
| Receive a socket, read the sending worker's id through it, send it back, and close it. | |
| static void | spin (uint32_t max_usec) |
| Busy wait for a random time up to max_usec. | |
| static void * | watchdog_thread (UNUSED void *arg) |
| Fail the test if the master stops receiving. | |
Variables | |
| static int | aq_size = 16 |
| static fr_control_t ** | control = NULL |
| static int | debug_lvl = 0 |
| static fr_event_list_t * | el = NULL |
| static bool | el_announces = false |
| the master never announces, the event list does it. | |
| static bool | finished = false |
| static size_t | max_messages = 10 |
| static uint32_t | max_pause_usec = 0 |
| workers pause up to this long between sends. | |
| static size_t | num_aq = 1 |
| static size_t | num_workers = 1 |
| static bool | single_aq = true |
| static uint32_t | watchdog_secs = 30 |
| fail if the master makes no progress for this long. | |
| static pthread_cond_t | wd_cond = PTHREAD_COND_INITIALIZER |
| static pthread_mutex_t | wd_mutex = PTHREAD_MUTEX_INITIALIZER |
| struct master_ctx_t |
Definition at line 109 of file control_test.c.
| Data Fields | ||
|---|---|---|
| size_t | num_messages | |
| size_t | num_sockets | |
| struct my_message_t |
Definition at line 103 of file control_test.c.
| Data Fields | ||
|---|---|---|
| size_t | counter | |
| uint32_t | header | |
| size_t | worker | |
| struct worker_args_t |
Definition at line 63 of file control_test.c.
| Data Fields | ||
|---|---|---|
| size_t | id | |
| #define CONTROL_MAGIC 0xabcd6809 |
Definition at line 47 of file control_test.c.
| #define MEM | ( | x | ) | do { if (!(x)) { fprintf(stderr, "%s[%d] OUT OF MEMORY\n", __FILE__, __LINE__); _exit(EXIT_FAILURE); } } while (0) |
Definition at line 43 of file control_test.c.
Definition at line 44 of file control_test.c.
Definition at line 45 of file control_test.c.
Definition at line 46 of file control_test.c.
| typedef enum control_test_event_t control_test_event_t |
Events on the test's control planes.
The test stands in for the network, and only needs one table.
| typedef enum control_test_socket_event_t control_test_socket_event_t |
Events whose messages carry a socket, numbered separately from those above.
| enum control_test_event_t : uint16_t |
Events on the test's control planes.
The test stands in for the network, and only needs one table.
| Enumerator | |
|---|---|
| CONTROL_TEST_MESSAGE | |
Definition at line 53 of file control_test.c.
Events whose messages carry a socket, numbered separately from those above.
| Enumerator | |
|---|---|
| CONTROL_TEST_SOCKET | one end of a socketpair, with the worker's id in it. |
Definition at line 59 of file control_test.c.
|
static |
Definition at line 82 of file control_test.c.
|
static |
|
static |
Definition at line 291 of file control_test.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Receive a socket, read the sending worker's id through it, send it back, and close it.
Definition at line 131 of file control_test.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Busy wait for a random time up to max_usec.
Deliberately a spin, so the worker never blocks and the master is the only thread which sleeps.
Definition at line 163 of file control_test.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Fail the test if the master stops receiving.
With the wakeup gated on the master announcing it is blocking, a missed wakeup leaves the master asleep with messages queued, which would otherwise hang the test rather than fail it.
Definition at line 181 of file control_test.c.
Here is the caller graph for this function:
|
static |
Definition at line 70 of file control_test.c.
|
static |
Definition at line 72 of file control_test.c.
|
static |
Definition at line 67 of file control_test.c.
|
static |
Definition at line 73 of file control_test.c.
|
static |
the master never announces, the event list does it.
Definition at line 71 of file control_test.c.
|
static |
Definition at line 81 of file control_test.c.
|
static |
Definition at line 68 of file control_test.c.
|
static |
workers pause up to this long between sends.
Definition at line 76 of file control_test.c.
|
static |
Definition at line 75 of file control_test.c.
|
static |
Definition at line 69 of file control_test.c.
|
static |
Definition at line 74 of file control_test.c.
|
static |
fail if the master makes no progress for this long.
Definition at line 77 of file control_test.c.
|
static |
Definition at line 80 of file control_test.c.
|
static |
Definition at line 79 of file control_test.c.
1.9.8