replmd: Refactor adding the backlink in replmd_process_linked_attribute()
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 18 Sep 2017 01:47:56 +0000 (13:47 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 20 Oct 2017 02:05:20 +0000 (04:05 +0200)
The code to add the backlink is the same in both the 'if' and the 'else'
case, so move it outside the if-else block.

(We're going to rework this block of code quite a bit in order to
support single-value linked attribute conflicts, aka bug #13055).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13055

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 2e0f7055e46483d4b4e7e3c1a9728261935de9b1..60a9c8c419100cae37da3c5b9202fd22843c6a86 100644 (file)
@@ -7301,19 +7301,6 @@ static int replmd_process_linked_attribute(struct ldb_module *module,
                        talloc_free(tmp_ctx);
                        return ret;
                }
                        talloc_free(tmp_ctx);
                        return ret;
                }
-
-               if (active) {
-                       /* add the new backlink */
-                       ret = replmd_add_backlink(module, replmd_private,
-                                                 schema, 
-                                                 msg->dn,
-                                                 &guid, true, attr,
-                                                 parent);
-                       if (ret != LDB_SUCCESS) {
-                               talloc_free(tmp_ctx);
-                               return ret;
-                       }
-               }
        } else {
                unsigned offset;
                /* get a seq_num for this change */
        } else {
                unsigned offset;
                /* get a seq_num for this change */
@@ -7367,17 +7354,18 @@ static int replmd_process_linked_attribute(struct ldb_module *module,
                        talloc_free(tmp_ctx);
                        return ret;
                }
                        talloc_free(tmp_ctx);
                        return ret;
                }
+       }
 
 
-               if (active) {
-                       ret = replmd_add_backlink(module, replmd_private,
-                                                 schema, 
-                                                 msg->dn,
-                                                 &guid, true, attr,
-                                                 parent);
-                       if (ret != LDB_SUCCESS) {
-                               talloc_free(tmp_ctx);
-                               return ret;
-                       }
+       /* if the new link is active, then add the new backlink */
+       if (active) {
+               ret = replmd_add_backlink(module, replmd_private,
+                                         schema,
+                                         msg->dn,
+                                         &guid, true, attr,
+                                         parent);
+               if (ret != LDB_SUCCESS) {
+                       talloc_free(tmp_ctx);
+                       return ret;
                }
        }
 
                }
        }