The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
worker.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: fb138f84a4068ba2ddc45f1acbf97afa8d06bf2d $
20 *
21 * @file io/worker.h
22 * @brief Functions and data structures for worker threads.
23 *
24 * @copyright 2016 Alan DeKok (aland@freeradius.org)
25 */
26RCSIDH(worker_h, "$Id: fb138f84a4068ba2ddc45f1acbf97afa8d06bf2d $")
27
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 * A data structure to track the worker.
35 *
36 * Once spawned, workers exist until they choose to exit.
37 */
38typedef struct fr_worker_s fr_worker_t;
39
40#ifdef __cplusplus
41}
42#endif
43
44#include <freeradius-devel/io/base.h>
45#include <freeradius-devel/server/command.h>
46#include <freeradius-devel/util/event.h>
47#include <freeradius-devel/util/heap.h>
48#include <freeradius-devel/util/log.h>
49#include <freeradius-devel/util/talloc.h>
50
51#include <pthread.h>
52
53#ifdef __cplusplus
54extern "C" {
55#endif
57
58typedef struct {
59 int max_requests; //!< max requests this worker will handle
60
61 int max_channels; //!< maximum number of channels
62
63 int message_set_size; //!< default start number of messages
64 int ring_buffer_size; //!< default start size for the ring buffers
65
66 fr_time_delta_t max_request_time; //!< maximum time a request can be processed
67
68 size_t talloc_pool_size; //!< for each request
70
71fr_worker_t *fr_worker_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const *name,
72 fr_log_t const *logger, fr_log_lvl_t lvl, fr_worker_config_t *config) CC_HINT(nonnull(2,3,4));
73
74void fr_worker_destroy(fr_worker_t *worker) CC_HINT(nonnull);
75
76void fr_worker(fr_worker_t *worker) CC_HINT(nonnull);
77
78void fr_worker_debug(fr_worker_t *worker, FILE *fp) CC_HINT(nonnull);
79
81
83
84fr_channel_t *fr_worker_channel_create(fr_worker_t *worker, TALLOC_CTX *ctx, fr_control_t *master) CC_HINT(nonnull);
85
86int fr_worker_stats(fr_worker_t const *worker, int num, uint64_t *stats) CC_HINT(nonnull);
87
88int fr_worker_listen_cancel(fr_worker_t *worker, fr_listen_t const *li);
89
90#include <freeradius-devel/server/module.h>
91
93
94#ifdef __cplusplus
95}
96#endif
#define RCSIDH(h, id)
Definition build.h:484
A full channel, which consists of two ends.
Definition channel.c:144
The control structure.
Definition control.c:79
Stores all information relating to an event list.
Definition event.c:411
fr_log_lvl_t
Definition log.h:67
static const conf_parser_t config[]
Definition base.c:183
static char const * name
Definition log.h:96
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
"server local" time.
Definition time.h:69
static fr_event_list_t * el
int nonnull(2, 5))
A worker which takes packets from a master, and processes them.
Definition worker.c:94
fr_channel_t * fr_worker_channel_create(fr_worker_t *worker, TALLOC_CTX *ctx, fr_control_t *master)
Create a channel to the worker.
Definition worker.c:1609
int message_set_size
default start number of messages
Definition worker.h:63
int fr_worker_subrequest_add(request_t *request)
fr_worker_t * fr_worker_create(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.
Definition worker.c:1356
fr_cmd_table_t cmd_worker_table[]
Definition worker.c:1738
int fr_worker_stats(fr_worker_t const *worker, int num, uint64_t *stats)
Definition worker.c:1685
int max_requests
max requests this worker will handle
Definition worker.h:59
int max_channels
maximum number of channels
Definition worker.h:61
int fr_worker_pre_event(fr_time_t now, fr_time_delta_t wake, void *uctx)
void fr_worker_destroy(fr_worker_t *worker)
Destroy a worker.
Definition worker.c:1012
void fr_worker_post_event(fr_event_list_t *el, fr_time_t now, void *uctx)
size_t talloc_pool_size
for each request
Definition worker.h:68
int fr_worker_listen_cancel(fr_worker_t *worker, fr_listen_t const *li)
Definition worker.c:1636
void fr_worker(fr_worker_t *worker)
The main loop and entry point of the stand-alone worker thread.
Definition worker.c:1493
int ring_buffer_size
default start size for the ring buffers
Definition worker.h:64
fr_time_delta_t max_request_time
maximum time a request can be processed
Definition worker.h:66
void fr_worker_debug(fr_worker_t *worker, FILE *fp)
Print debug information about the worker structure.
Definition worker.c:1584