if (gext->value) {
state->vpt = gext->vpt;
+ fr_assert(fr_pair_find_by_da(&request->local_pairs, NULL, gext->value) == NULL);
+
/*
* Create the local variable and populate its value.
*/
fr_assert(state->value != NULL);
if (gext->key) {
+ fr_assert(fr_pair_find_by_da(&request->local_pairs, NULL, gext->key) == NULL);
+
if (fr_pair_append_by_da(request->local_ctx, &state->key, &request->local_pairs, gext->key) < 0) {
REDEBUG("Failed creating %s", gext->key->name);
*p_result = RLM_MODULE_FAIL;
static int _local_variables_free(unlang_variable_ref_t *ref)
{
- fr_pair_list_foreach(&ref->request->local_pairs, vp) {
- if (vp->da->dict != ref->dict) break;
+ fr_pair_t *vp, *prev;
+
+ /*
+ * Local variables are appended to the end of the list. So we remove them by walking backwards
+ * from the end of the list.
+ */
+ vp = fr_pair_list_tail(&ref->request->local_pairs);
+ while (vp) {
+ prev = fr_pair_list_prev(&ref->request->local_pairs, vp);
+ if (vp->da->dict != ref->dict) {
+ break;
+ }
(void) fr_pair_delete(&ref->request->local_pairs, vp);
+ vp = prev;
}
return 0;
# PRE: foreach
#
-foreach Filter-Id {
- foreach Calling-Station-Id {
+foreach thing1 (Filter-Id[*]) {
+ foreach thing2 (Calling-Station-Id[*]) {
reply += {
- Called-Station-Id = "%{Foreach-Variable-0} %{Foreach-Variable-1}"
+ Called-Station-Id = "%{thing1} %{thing2}"
}
}
}