dlz_bind9: Do not remove LDB record in subrdataset and delrdataset
authorAmitay Isaacs <amitay@gmail.com>
Wed, 8 Feb 2012 23:17:02 +0000 (10:17 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 21 Feb 2012 07:24:30 +0000 (18:24 +1100)
This fixes the problem of large number of deleted records in DNS
partitions due to frequent dynamic dns updates from windows
clients. The typical pattern for dynamic update get converted
into subrdataset() followed by addrdataset().  If there are no
dnsRecord attributes left as a result of sub/delrdataset(),
leave the LDB entry for dns name as is. The subsequent
addrdataset() would add the dnsRecord attribute without
re-creating the same entry.

source4/dns_server/dlz_bind9.c

index 6f6b1da32e626497bd70766fa2ec9001ccf3850f..7bb7a3467cce17540868c1d46a3027fd25e9b7be 100644 (file)
@@ -1614,14 +1614,11 @@ _PUBLIC_ isc_result_t dlz_subrdataset(const char *name, const char *rdatastr, vo
        }
 
        if (el->num_values == 0) {
-               /* delete the record */
-               ret = ldb_delete(state->samdb, dn);
-               b9_reset_session_info(state);
-       } else {
-               /* modify the record */
-               el->flags = LDB_FLAG_MOD_REPLACE;
-               ret = ldb_modify(state->samdb, res->msgs[0]);
+               ldb_msg_remove_element(res->msgs[0], el);
        }
+       el->flags = LDB_FLAG_MOD_REPLACE;
+       ret = ldb_modify(state->samdb, res->msgs[0]);
+
        b9_reset_session_info(state);
        if (ret != LDB_SUCCESS) {
                state->log(ISC_LOG_ERROR, "samba_dlz: failed to modify %s - %s",
@@ -1722,13 +1719,11 @@ _PUBLIC_ isc_result_t dlz_delrdataset(const char *name, const char *type, void *
        }
 
        if (el->num_values == 0) {
-               /* delete the record */
-               ret = ldb_delete(state->samdb, dn);
-       } else {
-               /* modify the record */
-               el->flags = LDB_FLAG_MOD_REPLACE;
-               ret = ldb_modify(state->samdb, res->msgs[0]);
+               ldb_msg_remove_element(res->msgs[0], el);
        }
+       el->flags = LDB_FLAG_MOD_REPLACE;
+       ret = ldb_modify(state->samdb, res->msgs[0]);
+
        b9_reset_session_info(state);
        if (ret != LDB_SUCCESS) {
                state->log(ISC_LOG_ERROR, "samba_dlz: failed to delete type %s in %s - %s",