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: 85d724e53c6cd2d60772e23e651e13b9db458271 $
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: 85d724e53c6cd2d60772e23e651e13b9db458271 $")
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/slab.h>
50#include <freeradius-devel/util/talloc.h>
51
52#include <pthread.h>
53
54#ifdef __cplusplus
55extern "C" {
56#endif
58
59typedef struct {
60 int max_requests; //!< max requests this worker will handle
61
62 int max_channels; //!< maximum number of channels
63
64 int message_set_size; //!< default start number of messages
65 int ring_buffer_size; //!< default start size for the ring buffers
66
67 fr_time_delta_t max_request_time; //!< maximum time a request can be processed
68
69 fr_slab_config_t reuse; //!< slab allocator configuration
71
72int fr_worker_request_timeout_set(fr_worker_t *worker, request_t *request, fr_time_delta_t timeout) CC_HINT(nonnull);
73
74fr_worker_t *fr_worker_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, char const *name,
75 fr_log_t const *logger, fr_log_lvl_t lvl, fr_worker_config_t *config) CC_HINT(nonnull(2,3,4));
76
77void fr_worker_destroy(fr_worker_t *worker) CC_HINT(nonnull);
78
79void fr_worker(fr_worker_t *worker) CC_HINT(nonnull);
80
81void fr_worker_debug(fr_worker_t *worker, FILE *fp) CC_HINT(nonnull);
82
84
86
87fr_channel_t *fr_worker_channel_create(fr_worker_t *worker, TALLOC_CTX *ctx, fr_control_t *master) CC_HINT(nonnull);
88
89int fr_worker_stats(fr_worker_t const *worker, int num, uint64_t *stats) CC_HINT(nonnull);
90
91int fr_worker_listen_cancel(fr_worker_t *worker, fr_listen_t const *li);
92
93#include <freeradius-devel/server/module.h>
94
96
97#ifdef __cplusplus
98}
99#endif
#define RCSIDH(h, id)
Definition build.h:486
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:377
fr_log_lvl_t
Definition log.h:67
static const conf_parser_t config[]
Definition base.c:183
static char const * name
Tuneable parameters for slabs.
Definition slab.h:42
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:99
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:1654
int message_set_size
default start number of messages
Definition worker.h:64
int fr_worker_subrequest_add(request_t *request)
fr_cmd_table_t cmd_worker_table[]
Definition worker.c:1783
int fr_worker_stats(fr_worker_t const *worker, int num, uint64_t *stats)
Definition worker.c:1730
int max_requests
max requests this worker will handle
Definition worker.h:60
int max_channels
maximum number of channels
Definition worker.h:62
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:1029
void fr_worker_post_event(fr_event_list_t *el, fr_time_t now, void *uctx)
fr_worker_t * fr_worker_alloc(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:1383
int fr_worker_listen_cancel(fr_worker_t *worker, fr_listen_t const *li)
Definition worker.c:1681
int fr_worker_request_timeout_set(fr_worker_t *worker, request_t *request, fr_time_delta_t timeout)
Set, or re-set the request timer.
Definition worker.c:557
void fr_worker(fr_worker_t *worker)
The main loop and entry point of the stand-alone worker thread.
Definition worker.c:1538
fr_slab_config_t reuse
slab allocator configuration
Definition worker.h:69
int ring_buffer_size
default start size for the ring buffers
Definition worker.h:65
fr_time_delta_t max_request_time
maximum time a request can be processed
Definition worker.h:67
void fr_worker_debug(fr_worker_t *worker, FILE *fp)
Print debug information about the worker structure.
Definition worker.c:1629