traverse the ac list in reverse order
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 08:18:33 +0000 (18:18 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 08:19:56 +0000 (18:19 +1000)
items are added to the linked attribute list using DLIST_ADD(), which
means to commit them to the database in the same order they came from
the server we need to walk the list backwards when we traverse it

source4/dsdb/samdb/ldb_modules/linked_attributes.c

index 561fc669416316a4523848eb58da316976c31bcd..3486b7f2298d599c615cbfd4bbcd5231673550f9 100644 (file)
@@ -1243,7 +1243,12 @@ static int linked_attributes_end_transaction(struct ldb_module *module)
                talloc_get_type(ldb_module_get_private(module), struct la_private);
        struct la_context *ac;
 
-       for (ac=la_private->la_list; ac; ac=ac->next) {
+       /* walk the list backwards, to do the first entry first, as we
+        * added the entries with DLIST_ADD() which puts them at the
+        * start of the list */
+       for (ac = la_private->la_list; ac && ac->next; ac=ac->next) ;
+
+       for (; ac; ac=ac->prev) {
                int ret;
                ac->req = NULL;
                ret = la_do_mod_request(module, ac);