@@ -31,8 +31,6 @@ RCSID("$Id$")
3131#include <freeradius-devel/util/debug.h>
3232#include <freeradius-devel/util/atexit.h>
3333
34- static request_init_args_t default_args ;
35-
3634static fr_dict_t const * dict_freeradius ;
3735
3836extern fr_dict_autoload_t request_dict [];
@@ -198,7 +196,7 @@ static inline CC_HINT(always_inline) int request_detachable_init(request_t *chil
198196static inline CC_HINT (always_inline ) int request_child_init (request_t * child , request_t * parent )
199197{
200198 child -> number = parent -> child_number ++ ;
201- if (!child -> dict ) child -> dict = parent -> dict ;
199+ if (!child -> dict ) child -> local_dict = child -> dict = parent -> dict ;
202200
203201 if ((parent -> seq_start == 0 ) || (parent -> number == parent -> seq_start )) {
204202 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
243241 request_t * request , request_type_t type ,
244242 request_init_args_t const * args )
245243{
244+ fr_dict_t const * dict ;
246245
247246 /*
248247 * Sanity checks for different requests types
249248 */
250249 switch (type ) {
251250 case REQUEST_TYPE_EXTERNAL :
251+ fr_assert (args );
252+
252253 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 ;
253258 break ;
254259
255260 case REQUEST_TYPE_INTERNAL :
261+ if (!args || !args -> namespace ) {
262+ dict = fr_dict_internal ();
263+ } else {
264+ dict = args -> namespace ;
265+ }
256266 break ;
257267
258268 case REQUEST_TYPE_DETACHED :
@@ -267,10 +277,11 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line
267277#endif
268278 .type = type ,
269279 .master_state = REQUEST_ACTIVE ,
270- .dict = args -> namespace ,
280+ .dict = dict ,
281+ .local_dict = dict ,
271282 .component = "<pre-core>" ,
272283 .flags = {
273- .detachable = args -> detachable
284+ .detachable = args && args -> detachable ,
274285 },
275286 .alloc_file = file ,
276287 .alloc_line = line
@@ -306,7 +317,7 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line
306317 * the any uninitialised lists and
307318 * create them locally.
308319 */
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 ));
310321
311322#define list_init (_ctx , _list ) \
312323 do { \
@@ -337,7 +348,7 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line
337348 * fields if this is going to be a
338349 * child request.
339350 */
340- if (args -> parent ) {
351+ if (args && args -> parent ) {
341352 if (request_child_init (request , args -> parent ) < 0 ) return -1 ;
342353
343354 if (args -> detachable ) {
@@ -504,8 +515,6 @@ request_t *_request_alloc(char const *file, int line, TALLOC_CTX *ctx,
504515 request_t * request ;
505516 fr_dlist_head_t * free_list ;
506517
507- if (!args ) args = & default_args ;
508-
509518 /*
510519 * Setup the free list, or return the free
511520 * list for this thread.
@@ -610,8 +619,6 @@ request_t *_request_local_alloc(char const *file, int line, TALLOC_CTX *ctx,
610619{
611620 request_t * request ;
612621
613- if (!args ) args = & default_args ;
614-
615622 request = request_alloc_pool (ctx );
616623 if (request_init (file , line , request , type , args ) < 0 ) return NULL ;
617624
@@ -814,6 +821,9 @@ void request_verify(char const *file, int line, request_t const *request)
814821 fr_pair_list_verify (file , line , request -> session_state_ctx , & request -> session_state_pairs );
815822 fr_pair_list_verify (file , line , request -> local_ctx , & request -> local_pairs );
816823
824+ fr_assert (request -> dict != NULL );
825+ fr_assert (request -> local_dict != NULL );
826+
817827 if (request -> packet ) {
818828 packet_verify (file , line , request , request -> packet , & request -> request_pairs , "request" );
819829 }
0 commit comments