* Now that the CONF_SECTION and condition are OK, add
* the condition to the CONF_SECTION.
*/
- cf_data_add(cs, cond, NULL, false);
+ cf_data_add(cs, cond, NULL, true);
#ifdef WITH_XLAT_COND
- cf_data_add(cs, head, NULL, false);
+ cf_data_add(cs, head, NULL, true);
#endif
stack->ptr = ptr;
*/
void cf_item_free_children(CONF_ITEM *ci)
{
- fr_dlist_talloc_free(&ci->children);
- TALLOC_FREE(ci->ident1);
- TALLOC_FREE(ci->ident2);
+ CONF_ITEM *child = NULL;
+
+ while ((child = fr_dlist_next(&ci->children, child)) != NULL) {
+ if (child->type == CONF_ITEM_DATA) {
+ continue;
+ }
+
+ child = fr_dlist_talloc_free_item(&ci->children, child);
+ }
}
* So we skip this "elsif" or "else".
*/
if (skip_else) {
+ void *ptr;
+
+ /*
+ * And manually free this.
+ */
+ ptr = cf_data_remove(subcs, fr_cond_t, NULL);
+ talloc_free(ptr);
+ ptr = cf_data_remove(subcs, xlat_exp_head_t, NULL);
+ talloc_free(ptr);
+
+ cf_section_free_children(subcs);
+
cf_log_debug_prefix(ci, "Skipping contents of '%s' due to previous "
"'%s' being always being taken.",
name, skip_else);
* Free the children, which frees any xlats,
* conditions, etc. which were defined, but are
* now entirely unused.
+ *
+ * However, we still need to cache the conditions, as they will be accessed at run-time.
*/
- cf_section_free_children(cs);
c = compile_empty(parent, unlang_ctx, cs, ext);
+ cf_section_free_children(cs);
} else {
fr_cond_iter_t iter;
/*
* If we always run this condition, then don't bother pushing anything onto the stack.
+ *
+ * We still run this condition, even for "false" values, due to things like
+ *
+ * if (0) { ... } elsif ....
*/
if (gext->is_truthy) {
- fr_assert(gext->value); /* otherwise it would have been omitted from the unlang tree */
-
return unlang_group(p_result, request, frame);
}