@@ -31,8 +31,6 @@ RCSID("$Id$")
31
31
#include <freeradius-devel/util/debug.h>
32
32
#include <freeradius-devel/util/atexit.h>
33
33
34
- static request_init_args_t default_args ;
35
-
36
34
static fr_dict_t const * dict_freeradius ;
37
35
38
36
extern fr_dict_autoload_t request_dict [];
@@ -198,7 +196,7 @@ static inline CC_HINT(always_inline) int request_detachable_init(request_t *chil
198
196
static inline CC_HINT (always_inline ) int request_child_init (request_t * child , request_t * parent )
199
197
{
200
198
child -> number = parent -> child_number ++ ;
201
- if (!child -> dict ) child -> dict = parent -> dict ;
199
+ if (!child -> dict ) child -> local_dict = child -> dict = parent -> dict ;
202
200
203
201
if ((parent -> seq_start == 0 ) || (parent -> number == parent -> seq_start )) {
204
202
child -> name = talloc_typed_asprintf (child , "%s.%" PRIu64 , parent -> name , child -> number );
@@ -243,16 +241,28 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line
243
241
request_t * request , request_type_t type ,
244
242
request_init_args_t const * args )
245
243
{
244
+ fr_dict_t const * dict ;
246
245
247
246
/*
248
247
* Sanity checks for different requests types
249
248
*/
250
249
switch (type ) {
251
250
case REQUEST_TYPE_EXTERNAL :
251
+ fr_assert (args );
252
+
252
253
if (!fr_cond_assert_msg (!args -> parent , "External requests must NOT have a parent" )) return -1 ;
254
+
255
+ fr_assert (args -> namespace );
256
+
257
+ dict = args -> namespace ;
253
258
break ;
254
259
255
260
case REQUEST_TYPE_INTERNAL :
261
+ if (!args || !args -> namespace ) {
262
+ dict = fr_dict_internal ();
263
+ } else {
264
+ dict = args -> namespace ;
265
+ }
256
266
break ;
257
267
258
268
case REQUEST_TYPE_DETACHED :
@@ -267,10 +277,11 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line
267
277
#endif
268
278
.type = type ,
269
279
.master_state = REQUEST_ACTIVE ,
270
- .dict = args -> namespace ,
280
+ .dict = dict ,
281
+ .local_dict = dict ,
271
282
.component = "<pre-core>" ,
272
283
.flags = {
273
- .detachable = args -> detachable
284
+ .detachable = args && args -> detachable ,
274
285
},
275
286
.alloc_file = file ,
276
287
.alloc_line = line
@@ -306,7 +317,7 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line
306
317
* the any uninitialised lists and
307
318
* create them locally.
308
319
*/
309
- memcpy (& request -> pair_list , & args -> pair_list , sizeof (request -> pair_list ));
320
+ if ( args ) memcpy (& request -> pair_list , & args -> pair_list , sizeof (request -> pair_list ));
310
321
311
322
#define list_init (_ctx , _list ) \
312
323
do { \
@@ -337,7 +348,7 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line
337
348
* fields if this is going to be a
338
349
* child request.
339
350
*/
340
- if (args -> parent ) {
351
+ if (args && args -> parent ) {
341
352
if (request_child_init (request , args -> parent ) < 0 ) return -1 ;
342
353
343
354
if (args -> detachable ) {
@@ -504,8 +515,6 @@ request_t *_request_alloc(char const *file, int line, TALLOC_CTX *ctx,
504
515
request_t * request ;
505
516
fr_dlist_head_t * free_list ;
506
517
507
- if (!args ) args = & default_args ;
508
-
509
518
/*
510
519
* Setup the free list, or return the free
511
520
* list for this thread.
@@ -610,8 +619,6 @@ request_t *_request_local_alloc(char const *file, int line, TALLOC_CTX *ctx,
610
619
{
611
620
request_t * request ;
612
621
613
- if (!args ) args = & default_args ;
614
-
615
622
request = request_alloc_pool (ctx );
616
623
if (request_init (file , line , request , type , args ) < 0 ) return NULL ;
617
624
@@ -814,6 +821,9 @@ void request_verify(char const *file, int line, request_t const *request)
814
821
fr_pair_list_verify (file , line , request -> session_state_ctx , & request -> session_state_pairs );
815
822
fr_pair_list_verify (file , line , request -> local_ctx , & request -> local_pairs );
816
823
824
+ fr_assert (request -> dict != NULL );
825
+ fr_assert (request -> local_dict != NULL );
826
+
817
827
if (request -> packet ) {
818
828
packet_verify (file , line , request , request -> packet , & request -> request_pairs , "request" );
819
829
}
0 commit comments