mirror of
https://github.com/samba-team/samba.git
synced 2025-02-08 05:57:51 +03:00
dns scavenging: avoid useless copy of msg
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
444b8178b8
commit
4a2bfd249d
@ -97,7 +97,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
struct ldb_message_element *tombstone_el = NULL;
|
struct ldb_message_element *tombstone_el = NULL;
|
||||||
struct ldb_message_element *old_el = NULL;
|
struct ldb_message_element *old_el = NULL;
|
||||||
struct ldb_message *new_msg = NULL;
|
struct ldb_message *new_msg = NULL;
|
||||||
struct ldb_message *old_msg = NULL;
|
|
||||||
enum ndr_err_code ndr_err;
|
enum ndr_err_code ndr_err;
|
||||||
int ret;
|
int ret;
|
||||||
struct GUID guid;
|
struct GUID guid;
|
||||||
@ -178,28 +177,21 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
* change. This prevents race conditions.
|
* change. This prevents race conditions.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < res->count; i++) {
|
for (i = 0; i < res->count; i++) {
|
||||||
old_msg = ldb_msg_copy(mem_ctx, res->msgs[i]);
|
new_msg = ldb_msg_copy(mem_ctx, res->msgs[i]);
|
||||||
if (old_msg == NULL) {
|
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
old_el = ldb_msg_find_element(old_msg, "dnsRecord");
|
|
||||||
if (old_el == NULL) {
|
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
old_el->flags = LDB_FLAG_MOD_DELETE;
|
|
||||||
new_msg = ldb_msg_copy(mem_ctx, old_msg);
|
|
||||||
if (new_msg == NULL) {
|
if (new_msg == NULL) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
old_el = ldb_msg_find_element(new_msg, "dnsRecord");
|
||||||
|
if (old_el == NULL) {
|
||||||
|
TALLOC_FREE(new_msg);
|
||||||
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
old_el->flags = LDB_FLAG_MOD_DELETE;
|
||||||
|
|
||||||
ret = ldb_msg_add_empty(
|
ret = ldb_msg_add_empty(
|
||||||
new_msg, "dnsRecord", LDB_FLAG_MOD_ADD, &el);
|
new_msg, "dnsRecord", LDB_FLAG_MOD_ADD, &el);
|
||||||
if (ret != LDB_SUCCESS) {
|
if (ret != LDB_SUCCESS) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -207,7 +199,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
status = copy_current_records(mem_ctx, old_el, el, dns_timestamp);
|
status = copy_current_records(mem_ctx, old_el, el, dns_timestamp);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -215,7 +206,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
/* If nothing was expired, do nothing. */
|
/* If nothing was expired, do nothing. */
|
||||||
if (el->num_values == old_el->num_values &&
|
if (el->num_values == old_el->num_values &&
|
||||||
el->num_values != 0) {
|
el->num_values != 0) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -238,7 +228,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
struct ldb_val,
|
struct ldb_val,
|
||||||
1);
|
1);
|
||||||
if (!vals) {
|
if (!vals) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -255,7 +244,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
&true_val,
|
&true_val,
|
||||||
&tombstone_el);
|
&tombstone_el);
|
||||||
if (ret != LDB_SUCCESS) {
|
if (ret != LDB_SUCCESS) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -268,7 +256,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
struct ldb_val,
|
struct ldb_val,
|
||||||
1);
|
1);
|
||||||
if (!vals) {
|
if (!vals) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -290,7 +277,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
/* Set DN to the GUID in case the object was moved. */
|
/* Set DN to the GUID in case the object was moved. */
|
||||||
el = ldb_msg_find_element(new_msg, "objectGUID");
|
el = ldb_msg_find_element(new_msg, "objectGUID");
|
||||||
if (el == NULL) {
|
if (el == NULL) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
*error_string =
|
*error_string =
|
||||||
talloc_asprintf(mem_ctx,
|
talloc_asprintf(mem_ctx,
|
||||||
@ -302,7 +288,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
status = GUID_from_ndr_blob(el->values, &guid);
|
status = GUID_from_ndr_blob(el->values, &guid);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
*error_string =
|
*error_string =
|
||||||
discard_const_p(char, "Error: Invalid GUID.\n");
|
discard_const_p(char, "Error: Invalid GUID.\n");
|
||||||
@ -318,7 +303,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
ret = ldb_modify(samdb, new_msg);
|
ret = ldb_modify(samdb, new_msg);
|
||||||
if (ret != LDB_SUCCESS) {
|
if (ret != LDB_SUCCESS) {
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
*error_string =
|
*error_string =
|
||||||
talloc_asprintf(mem_ctx,
|
talloc_asprintf(mem_ctx,
|
||||||
@ -328,7 +312,6 @@ static NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
|
|||||||
ldb_errstring(samdb));
|
ldb_errstring(samdb));
|
||||||
return NT_STATUS_INTERNAL_ERROR;
|
return NT_STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
TALLOC_FREE(old_msg);
|
|
||||||
TALLOC_FREE(new_msg);
|
TALLOC_FREE(new_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user