The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
schedule.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: aaae2c4019f8306f464491cd81b793693d870c2a $
20 *
21 * @file io/schedule.h
22 * @brief Scheduler communication.
23 *
24 * @copyright 2016 Alan DeKok (aland@freeradius.org)
25 */
26RCSIDH(schedule_h, "$Id: aaae2c4019f8306f464491cd81b793693d870c2a $")
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
33
34#ifdef __cplusplus
35}
36#endif
37
38#include <freeradius-devel/io/channel.h>
39#include <freeradius-devel/io/network.h>
40#include <freeradius-devel/io/worker.h>
41#include <freeradius-devel/io/coord.h>
42#include <freeradius-devel/util/log.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47/** Setup a new thread
48 *
49 * @param[in] ctx to allocate any thread specific memory in.
50 * @param[in] el Event list used by the thread.
51 * @param[in] uctx User data passed to callback.
52 * @return
53 * - 0 on success.
54 * - -1 on failure.
55 */
56typedef int (*fr_schedule_thread_instantiate_t)(TALLOC_CTX *ctx, fr_event_list_t *el, void *uctx);
57
58/** Explicitly free resources allocated by #fr_schedule_thread_instantiate_t
59 *
60 * @param[in] uctx User data passed to callback.
61 */
62typedef void (*fr_schedule_thread_detach_t)(void *uctx);
63
64typedef struct {
65 uint32_t max_networks; //!< number of network threads
66 uint32_t max_workers; //!< number of worker threads
67
68 fr_worker_config_t worker; //!< configuration for each worker
69 fr_network_config_t network; //!< configuration for each network;
70
71 fr_time_delta_t stats_interval; //!< print channel statistics
72
73 CONF_SECTION *cs; //!< root config section
75
76int fr_schedule_worker_id(void);
77
78fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, bool single_threaded, fr_event_list_t *el,
79 fr_log_t *log, fr_log_lvl_t lvl,
80 fr_schedule_thread_instantiate_t worker_thread_instantiate,
81 fr_schedule_thread_detach_t worker_thread_detach,
83/* schedulers are async, so there's no fr_schedule_run() */
85
88#ifdef __cplusplus
89}
90#endif
#define RCSIDH(h, id)
Definition build.h:507
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
Stores all information relating to an event list.
Definition event.c:377
fr_log_lvl_t
Definition log.h:64
unsigned int uint32_t
static const conf_parser_t config[]
Definition base.c:163
The scheduler.
Definition schedule.c:76
fr_network_config_t network
configuration for each network;
Definition schedule.h:69
uint32_t max_workers
number of worker threads
Definition schedule.h:66
int(* fr_schedule_thread_instantiate_t)(TALLOC_CTX *ctx, fr_event_list_t *el, void *uctx)
Setup a new thread.
Definition schedule.h:56
fr_network_t * fr_schedule_directory_add(fr_schedule_t *sc, fr_listen_t *li)
Add a directory NOTE_EXTEND to a scheduler.
Definition schedule.c:735
fr_network_t * fr_schedule_listen_add(fr_schedule_t *sc, fr_listen_t *li)
Add a fr_listen_t to a scheduler.
Definition schedule.c:703
void(* fr_schedule_thread_detach_t)(void *uctx)
Explicitly free resources allocated by fr_schedule_thread_instantiate_t.
Definition schedule.h:62
CONF_SECTION * cs
root config section
Definition schedule.h:73
int fr_schedule_worker_id(void)
Return the worker id for the current thread.
Definition schedule.c:110
fr_schedule_t * fr_schedule_create(TALLOC_CTX *ctx, bool single_threaded, fr_event_list_t *el, fr_log_t *log, fr_log_lvl_t lvl, fr_schedule_thread_instantiate_t worker_thread_instantiate, fr_schedule_thread_detach_t worker_thread_detach, fr_schedule_config_t *config))
Create a scheduler and spawn the child threads.
Definition schedule.c:266
fr_worker_config_t worker
configuration for each worker
Definition schedule.h:68
fr_time_delta_t stats_interval
print channel statistics
Definition schedule.h:71
uint32_t max_networks
number of network threads
Definition schedule.h:65
int fr_schedule_destroy(fr_schedule_t **sc)
Destroy a scheduler, and tell its child threads to exit.
Definition schedule.c:571
static const uchar sc[16]
Definition smbdes.c:115
Definition log.h:93
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
static fr_event_list_t * el
int nonnull(2, 5))