]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Update callback for dcursor pair removal
authorNick Porter <nick@portercomputing.co.uk>
Tue, 24 Jan 2023 11:25:04 +0000 (11:25 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 9 Feb 2023 17:00:06 +0000 (11:00 -0600)
To handle removing pairs from child lists

src/lib/util/pair.c

index 925e2f80f73e62c7e503d0b0cb42ac715e6963cc..2c39808477c01dc0cde983367d50f1f6cca7b546 100644 (file)
@@ -989,7 +989,7 @@ static int _pair_list_dcursor_insert(fr_dlist_head_t *list, void *to_insert, UNU
        return 0;
 }
 
-/** Keep attr tree and sublists synced on cursor insert
+/** Keep attr tree and sublists synced on cursor removal
  *
  * @param[in] list     Underlying order list from the fr_pair_list_t.
  * @param[in] to_remove        fr_pair_t being removed.
@@ -1000,13 +1000,20 @@ static int _pair_list_dcursor_insert(fr_dlist_head_t *list, void *to_insert, UNU
 static int _pair_list_dcursor_remove(NDEBUG_UNUSED fr_dlist_head_t *list, void *to_remove, UNUSED void *uctx)
 {
        fr_pair_t *vp = to_remove;
+       fr_pair_list_t *parent = fr_pair_parent_list(vp);
 
 #ifndef NDEBUG
        fr_tlist_head_t *tlist;
 
        tlist = fr_tlist_head_from_dlist(list);
 
+       while (parent && (tlist != vp->order_entry.entry.list_head)) {
+               tlist = &parent->order.head;
+               parent = fr_pair_parent_list(fr_pair_list_parent(parent));
+       }
+
        fr_assert(vp->order_entry.entry.list_head == tlist);
+       parent = fr_pair_parent_list(vp);
 #endif
 
        /*
@@ -1016,7 +1023,10 @@ static int _pair_list_dcursor_remove(NDEBUG_UNUSED fr_dlist_head_t *list, void *
 
        PAIR_VERIFY(vp);
 
-       return 0;
+       if (&parent->order.head.dlist_head == list) return 0;
+
+       fr_pair_remove(parent, vp);
+       return 1;
 }
 
 /** Initialises a special dcursor with callbacks that will maintain the attr sublists correctly