]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Alloc a pooled object for the stack, so we can use mutable frame extensions without...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 24 May 2017 23:08:45 +0000 (19:08 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 24 May 2017 23:08:45 +0000 (19:08 -0400)
src/include/interpreter.h
src/main/request.c

index fb87483e30297f2493ad684f1112999b76128589..fbc25e65eace2a10f9359316af9a98bd0c330599 100644 (file)
@@ -218,6 +218,12 @@ typedef struct {
        unlang_t                *found;
 } unlang_stack_entry_redundant_t;
 
+typedef union {
+       unlang_stack_entry_modcall_t    modcall;        //!< State for a modcall.
+       unlang_stack_entry_foreach_t    foreach;        //!< Foreach iterator state.
+       unlang_stack_entry_redundant_t  redundant;      //!< Redundant section state.
+} unlang_stack_entry_t;
+
 /** Our interpreter stack, as distinct from the C stack
  *
  * We don't call the modules recursively.  Instead we iterate over a list of #unlang_t and
index 863b9533caec4e770bc51793d3b79e7ce44e1b9d..d593e3fd4987a093373142f1bd02afa0f45d4364 100644 (file)
@@ -110,7 +110,26 @@ REQUEST *request_alloc(TALLOC_CTX *ctx)
 
        request->module = NULL;
        request->component = "<core>";
+
+#ifdef HAVE_TALLOC_POOLED_OBJECT
+       /*
+        *      If we have talloc_pooled_object allocate the
+        *      stack as a combined chunk/pool, with memory
+        *      to hold at mutable data for at least a quarter
+        *      of the maximum number of stack frames.
+        *
+        *      Having a dedicated pool for mutable stack data
+        *      means we don't have memory fragmentations issues
+        *      as we would if request were used as the pool.
+        *
+        *      This number is pretty arbitrary, but it seems
+        *      like too low level to make into a tuneable.
+        */
+       request->stack = talloc_pooled_object(request, unlang_stack_t, UNLANG_STACK_MAX / 4,
+                                             sizeof(unlang_stack_entry_t));
+#else
        request->stack = talloc_zero(request, unlang_stack_t);
+#endif
        request->heap_id = -1;
 
        request->state_ctx = talloc_init("session-state");