summaryrefslogtreecommitdiff
path: root/source3/libnet
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-07-30 12:00:49 +0200
committerMichael Adam <obnox@samba.org>2008-08-01 16:07:04 +0200
commit9e1eccc9112eb64cfd64781941811267a02866de (patch)
tree071e4a8ceac064c9825e97573ee45ef99a3fe45f /source3/libnet
parent58e0b8d56859ff179387025424af69f3fc3f61d8 (diff)
downloadsamba-9e1eccc9112eb64cfd64781941811267a02866de.tar.gz
samba-9e1eccc9112eb64cfd64781941811267a02866de.tar.bz2
samba-9e1eccc9112eb64cfd64781941811267a02866de.zip
libnet dssync: simplify logic of libnet_dssync_process() main loop.
Untangle parsing of results and processing. Make loop logic more obvious. Call finishing operation after the loop, not inside. Michael (This used to be commit 47c8b3391cb1bb9656f93b55f9ea39c78b74ed36)
Diffstat (limited to 'source3/libnet')
-rw-r--r--source3/libnet/libnet_dssync.c147
1 files changed, 64 insertions, 83 deletions
diff --git a/source3/libnet/libnet_dssync.c b/source3/libnet/libnet_dssync.c
index b93f906de2..11ebf2ae3b 100644
--- a/source3/libnet/libnet_dssync.c
+++ b/source3/libnet/libnet_dssync.c
@@ -479,6 +479,7 @@ static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
struct replUpToDateVectorBlob *pnew_utdv = NULL;
int32_t out_level = 0;
int y;
+ bool last_query;
const char *dn;
status = ctx->ops->startup(ctx, mem_ctx, &old_utdv);
@@ -512,13 +513,9 @@ static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
goto out;
}
- if (!ctx->single) {
- pnew_utdv = &new_utdv;
- }
-
- for (y=0; ;y++) {
-
- bool last_query = true;
+ for (y=0, last_query = false; !last_query; y++) {
+ struct drsuapi_DsReplicaObjectListItemEx *first_object;
+ struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
if (level == 8) {
DEBUG(1,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y,
@@ -555,14 +552,14 @@ static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
} else if (level_out == 2) {
out_level = 1;
ctr1 = ctr.ctr2.ctr.mszip1.ctr1;
- }
-
- status = cli_get_session_key(mem_ctx, ctx->cli, &ctx->session_key);
- if (!NT_STATUS_IS_OK(status)) {
- ctx->error_message = talloc_asprintf(mem_ctx,
- "Failed to get Session Key: %s",
- nt_errstr(status));
- return status;
+ } else if (level_out == 6) {
+ out_level = 6;
+ ctr6 = &ctr.ctr6;
+ } else if (level_out == 7
+ && ctr.ctr7.level == 6
+ && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) {
+ out_level = 6;
+ ctr6 = ctr.ctr7.ctr.mszip6.ctr6;
}
if (out_level == 1) {
@@ -570,96 +567,80 @@ static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
(long long)ctr1->new_highwatermark.tmp_highest_usn,
(long long)ctr1->new_highwatermark.highest_usn));
- libnet_dssync_decrypt_attributes(mem_ctx,
- &ctx->session_key,
- ctr1->first_object);
+ first_object = ctr1->first_object;
+ mapping_ctr = &ctr1->mapping_ctr;
if (ctr1->more_data) {
req.req5.highwatermark = ctr1->new_highwatermark;
- last_query = false;
- }
-
- if (ctx->ops->process_objects) {
- status = ctx->ops->process_objects(ctx, mem_ctx,
- ctr1->first_object,
- &ctr1->mapping_ctr);
- if (!NT_STATUS_IS_OK(status)) {
- ctx->error_message = talloc_asprintf(mem_ctx,
- "Failed to call processing function: %s",
- nt_errstr(status));
- goto out;
+ } else {
+ last_query = true;
+ ZERO_STRUCT(new_utdv);
+ new_utdv.version = 1;
+ if (ctr1->uptodateness_vector) {
+ new_utdv.ctr.ctr1.count =
+ ctr1->uptodateness_vector->count;
+ new_utdv.ctr.ctr1.cursors =
+ ctr1->uptodateness_vector->cursors;
}
}
-
- if (!last_query) {
- continue;
- }
-
- ZERO_STRUCT(new_utdv);
- new_utdv.version = 1;
- if (ctr1->uptodateness_vector) {
- new_utdv.ctr.ctr1.count = ctr1->uptodateness_vector->count;
- new_utdv.ctr.ctr1.cursors = ctr1->uptodateness_vector->cursors;
- }
- }
-
- if (level_out == 6) {
- out_level = 6;
- ctr6 = &ctr.ctr6;
- } else if (level_out == 7
- && ctr.ctr7.level == 6
- && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) {
- out_level = 6;
- ctr6 = ctr.ctr7.ctr.mszip6.ctr6;
- }
-
- if (out_level == 6) {
+ } else if (out_level == 6) {
DEBUG(1,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y,
(long long)ctr6->new_highwatermark.tmp_highest_usn,
(long long)ctr6->new_highwatermark.highest_usn));
- libnet_dssync_decrypt_attributes(mem_ctx,
- &ctx->session_key,
- ctr6->first_object);
+ first_object = ctr6->first_object;
+ mapping_ctr = &ctr6->mapping_ctr;
if (ctr6->more_data) {
req.req8.highwatermark = ctr6->new_highwatermark;
- last_query = false;
- }
-
- if (ctx->ops->process_objects) {
- status = ctx->ops->process_objects(ctx, mem_ctx,
- ctr6->first_object,
- &ctr6->mapping_ctr);
- if (!NT_STATUS_IS_OK(status)) {
- ctx->error_message = talloc_asprintf(mem_ctx,
- "Failed to call processing function: %s",
- nt_errstr(status));
- goto out;
+ } else {
+ last_query = true;
+ ZERO_STRUCT(new_utdv);
+ new_utdv.version = 2;
+ if (ctr6->uptodateness_vector) {
+ new_utdv.ctr.ctr2.count =
+ ctr6->uptodateness_vector->count;
+ new_utdv.ctr.ctr2.cursors =
+ ctr6->uptodateness_vector->cursors;
}
}
-
- if (!last_query) {
- continue;
- }
-
- ZERO_STRUCT(new_utdv);
- new_utdv.version = 2;
- if (ctr6->uptodateness_vector) {
- new_utdv.ctr.ctr2.count = ctr6->uptodateness_vector->count;
- new_utdv.ctr.ctr2.cursors = ctr6->uptodateness_vector->cursors;
- }
}
- status = ctx->ops->finish(ctx, mem_ctx, pnew_utdv);
+ status = cli_get_session_key(mem_ctx, ctx->cli, &ctx->session_key);
if (!NT_STATUS_IS_OK(status)) {
ctx->error_message = talloc_asprintf(mem_ctx,
- "Failed to call finishing operation: %s",
+ "Failed to get Session Key: %s",
nt_errstr(status));
goto out;
}
- break;
+ libnet_dssync_decrypt_attributes(mem_ctx,
+ &ctx->session_key,
+ first_object);
+
+ if (ctx->ops->process_objects) {
+ status = ctx->ops->process_objects(ctx, mem_ctx,
+ first_object,
+ mapping_ctr);
+ if (!NT_STATUS_IS_OK(status)) {
+ ctx->error_message = talloc_asprintf(mem_ctx,
+ "Failed to call processing function: %s",
+ nt_errstr(status));
+ goto out;
+ }
+ }
+ }
+
+ if (!ctx->single) {
+ pnew_utdv = &new_utdv;
+ }
+
+ status = ctx->ops->finish(ctx, mem_ctx, pnew_utdv);
+ if (!NT_STATUS_IS_OK(status)) {
+ ctx->error_message = talloc_asprintf(mem_ctx,
+ "Failed to call finishing operation: %s",
+ nt_errstr(status));
+ goto out;
}
out: