The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
io.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 
17 /**
18  * $Id: ca1fdd5f672ff4d68a7b2483e53367211a79d1ea $
19  *
20  * @file unlang/io.c
21  * @brief Shim I/O worker functions for running fake requests.
22  *
23  * @copyright 2006-2019 The FreeRADIUS server project
24  */
25 RCSID("$Id: ca1fdd5f672ff4d68a7b2483e53367211a79d1ea $")
26 
27 #include <freeradius-devel/io/listen.h>
28 #include "unlang_priv.h"
29 
30 /** Allocate a child request based on the parent.
31  *
32  * @param[in] parent spawning the child request.
33  * @param[in] namespace the child request operates in. If NULL the parent's namespace is used.
34  * @param[in] detachable Allow/disallow the child to be detached.
35  * @return
36  * - The new child request.
37  * - NULL on error.
38  */
39 request_t *unlang_io_subrequest_alloc(request_t *parent, fr_dict_t const *namespace, bool detachable)
40 {
41  request_t *child;
42 
43  child = request_alloc_internal(detachable ? NULL : parent,
45  .parent = parent,
46  .namespace = namespace,
47  .detachable = detachable
48  }));
49  if (!child) return NULL;
50 
51  /*
52  * Child gets its parent's interpreter
53  */
54  ((unlang_stack_t *)child->stack)->intp = ((unlang_stack_t *)parent->stack)->intp;
55 
56  /*
57  * Push the child, and set it's top frame to be true.
58  */
59  child->log.indent.unlang = parent->log.indent.unlang;
60 
61  /*
62  * Initialize some basic information for the child.
63  */
64  child->number = parent->number;
65 
66  /*
67  * Initialize all of the async fields.
68  */
69  child->async = talloc_zero(child, fr_async_t);
70 
71 #define COPY_FIELD(_x) child->async->_x = parent->async->_x
72  COPY_FIELD(recv_time);
74 
75  REQUEST_VERIFY(child);
76 
77  return child;
78 }
#define RCSID(id)
Definition: build.h:481
Minimal data structure to use the new code.
Definition: listen.h:58
request_t * unlang_io_subrequest_alloc(request_t *parent, fr_dict_t const *namespace, bool detachable)
Allocate a child request based on the parent.
Definition: io.c:39
#define COPY_FIELD(_x)
#define REQUEST_VERIFY(_x)
Definition: request.h:276
#define request_alloc_internal(_ctx, _args)
Allocate a new internal request.
Definition: request.h:305
#define request_is_internal(_x)
Definition: request.h:159
Optional arguments for initialising requests.
Definition: request.h:254
fr_assert(0)
Private interpreter structures and functions.
An unlang stack associated with a request.
Definition: unlang_priv.h:314
static fr_slen_t parent
Definition: pair.h:851