The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
child_request_priv.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, or (at your option)
6 * 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 Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18/**
19 * $Id: b89e75a0281a0801cd28435093531c701f4e48fe $
20 *
21 * @file unlang/subrequest_child_priv.h
22 *
23 * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
24 */
25#include <freeradius-devel/unlang/interpret.h>
26#include <freeradius-devel/server/request.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32
33/** Parallel child states
34 *
35 */
36typedef enum {
37 CHILD_INIT = 0, //!< Initial state, has no request allocated.
38
39 CHILD_RUNNABLE, //!< Running/runnable. The request is currently
40 ///< running, or is yielded but runnable.
41 CHILD_EXITED, //!< Child has run to completion, and is waiting
42 ///< to be reaped.
43 CHILD_DETACHED, //!< Child has detached, we can't signal it or
44 ///< communicate with it anymore. It will be freed
45 ///< by the interpreter when it completes.
46 CHILD_CANCELLED, //!< Child was cancelled. The request is still
47 ///< available, but the result from it should not
48 ///< be used and it should be free by the parent.
49 CHILD_DONE, //!< The child has been processed by the parent
50 ///< the request should still exist, and should be freed.
51
52 CHILD_FREED //!< The child has been freed. The request is no
53 ///< longer available, and should not be used.
54 ///< this is mostly for debugging purposes.
56
59
60/** Each child has a state, a number, a request, and a count of their siblings
61 */
62typedef struct {
63 char const *name; //!< Cache the request name.
64 int num; //!< The child number.
65 request_t *request; //!< Child request. The actual request the child will run.
66
67 unlang_child_request_state_t state; //!< State of the child.
68
69 unsigned int *sibling_count; //!< Number of siblings.
70 ///< as a child completes, it decrements this number.
71 ///< once it reaches zero, the parent is signalled
72 ///< to resume.
73
74 struct {
75 void const *session_unique_ptr; //!< Session unique ptr identifier. If not NULL, the child's
76 ///< session data will be stored in the parent, and be restored
77 ///< during a later request.
78 bool free_child;
80
81 unlang_result_t *p_result; //!< Pointer to the result of the child request.
82 ///< This is a pointer to the parent's result, and
83 ///< should be used to store the result of the child.
84 unlang_result_t result; //!< The result of the child request. This is a copy of the
85 ///< parent's result, and should be used to store the result
86 ///< of the child.
88
90 unlang_result_t *p_result, unsigned int *sibling_count, void const *unique_session_ptr, bool free_child);
91
93
94#ifdef __cplusplus
95}
96#endif
request_t * request
Child request. The actual request the child will run.
unlang_result_t result
The result of the child request.
int unlang_child_request_op_init(void)
fr_table_num_ordered_t const unlang_child_states_table[]
char const * name
Cache the request name.
unlang_child_request_state_t state
State of the child.
unsigned int * sibling_count
Number of siblings.
unlang_result_t * p_result
Pointer to the result of the child request.
unlang_child_request_state_t
Parallel child states.
@ CHILD_RUNNABLE
Running/runnable.
@ CHILD_DETACHED
Child has detached, we can't signal it or communicate with it anymore.
@ CHILD_INIT
Initial state, has no request allocated.
@ CHILD_EXITED
Child has run to completion, and is waiting to be reaped.
@ CHILD_CANCELLED
Child was cancelled.
@ CHILD_FREED
The child has been freed.
@ CHILD_DONE
The child has been processed by the parent the request should still exist, and should be freed.
int num
The child number.
int unlang_child_request_init(TALLOC_CTX *ctx, unlang_child_request_t *out, request_t *child, unlang_result_t *p_result, unsigned int *sibling_count, void const *unique_session_ptr, bool free_child)
Initialize a child request.
size_t unlang_child_states_table_len
Each child has a state, a number, a request, and a count of their siblings.
static const conf_parser_t config[]
Definition base.c:186
An element in an arbitrarily ordered array of name to num mappings.
Definition table.h:57
static size_t char ** out
Definition value.h:1020