Author: metze Date: 2005-08-29 14:58:03 +0000 (Mon, 29 Aug 2005) New Revision: 9740
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9740 Log: fix up the DsGetNCchanges loop, and remove misleading comments metze Modified: branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c Changeset: Modified: branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c =================================================================== --- branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c 2005-08-29 14:55:40 UTC (rev 9739) +++ branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c 2005-08-29 14:58:03 UTC (rev 9740) @@ -737,7 +737,7 @@ NTSTATUS status; BOOL ret = True; int i, y = 0; - int tmp_usn = 0; + uint64_t highest_usn = 0; const char *partition = NULL; struct drsuapi_DsGetNCChanges r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -759,12 +759,14 @@ ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); - partition = lp_parm_string(-1, "drsuapi", "partition"); + partition = lp_parm_string(-1, "dssync", "partition"); if (partition == NULL) { partition = ctx->domain_dn; - printf("drsuapi:partition not specified, defaulting to %s.\n", ctx->domain_dn); + printf("dssync:partition not specified, defaulting to %s.\n", ctx->domain_dn); } - + + highest_usn = lp_parm_int(-1, "dssync", "highest_usn", 0); + for (i=0; i < ARRAY_SIZE(array); i++) { printf("testing DsGetNCChanges level %d\n", array[i].level); @@ -781,15 +783,15 @@ r.in.req.req5.destination_dsa_guid = ctx->new_dc.invocation_id; r.in.req.req5.source_dsa_guid = null_guid; r.in.req.req5.naming_context = &nc; - r.in.req.req5.highwatermark.tmp_highest_usn = 0; + r.in.req.req5.highwatermark.tmp_highest_usn = highest_usn; r.in.req.req5.highwatermark.reserved_usn = 0; - r.in.req.req5.highwatermark.highest_usn = 0; + r.in.req.req5.highwatermark.highest_usn = highest_usn; r.in.req.req5.uptodateness_vector = NULL; r.in.req.req5.replica_flags = 0; - if (lp_parm_bool(-1,"drsuapi","compression",False)) { + if (lp_parm_bool(-1,"dssync","compression",False)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(-1,"drsuapi","neighbour_writeable",True)) { + if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP @@ -812,15 +814,15 @@ r.in.req.req8.destination_dsa_guid = ctx->new_dc.invocation_id; r.in.req.req8.source_dsa_guid = null_guid; r.in.req.req8.naming_context = &nc; - r.in.req.req8.highwatermark.tmp_highest_usn = 0; + r.in.req.req8.highwatermark.tmp_highest_usn = highest_usn; r.in.req.req8.highwatermark.reserved_usn = 0; - r.in.req.req8.highwatermark.highest_usn = 0; + r.in.req.req8.highwatermark.highest_usn = highest_usn; r.in.req.req8.uptodateness_vector = NULL; r.in.req.req8.replica_flags = 0; - if (lp_parm_bool(-1,"drsuapi","compression",False)) { + if (lp_parm_bool(-1,"dssync","compression",False)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(-1,"drsuapi","neighbour_writeable",True)) { + if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP @@ -842,27 +844,18 @@ ZERO_STRUCT(r.out); printf("Dumping AD partition: %s\n", nc.dn); - do { - /*r.in.req.req8.highwatermark = r.out.ctr.ctr6.new_highwatermark;*/ - /* - by setting r.in.req.req8.highwatermark.highest_usn to be the usn of the last update we received - (r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn from the last run), - we can get just the updates that have happened since then. - */ - - r.in.req.req8.highwatermark.tmp_highest_usn = 0; - tmp_usn = lp_parm_int(-1, "drsuapi", "last_usn", 0); - r.in.req.req8.highwatermark.highest_usn = tmp_usn; - - ZERO_STRUCT(r.out); + for (y=0; ;y++) { + if (r.in.level == 8) { + r.in.req.req8.highwatermark = r.out.ctr.ctr6.new_highwatermark; + ZERO_STRUCT(r.out); -DEBUG(0,("start[%d] tmp: %llu , hi: %llu\n",y, - r.in.req.req8.highwatermark.tmp_highest_usn, - r.in.req.req8.highwatermark.highest_usn)); + DEBUG(0,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y, + r.in.req.req8.highwatermark.tmp_highest_usn, + r.in.req.req8.highwatermark.highest_usn)); + } status = dcerpc_drsuapi_DsGetNCChanges(ctx->new_dc.drsuapi.pipe, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { @@ -874,31 +867,19 @@ printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result)); ret = False; } - -DEBUG(0,("end[%d] tmp: %llu , hi: %llu\n",y, - r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn, - r.out.ctr.ctr6.new_highwatermark.highest_usn)); - y++; - r.in.req.req8.highwatermark.tmp_highest_usn += 100000; - printf("The current highwatermark value (latest USN) = %llu. Temporary Maximum = %llu \n", - r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn, r.in.req.req8.highwatermark.tmp_highest_usn); - /* } while (ret == True && r.out.level == 6 && - r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn != r.out.ctr.ctr6.new_highwatermark.highest_usn); - */ - printf("r.in.level = %d.\nr.out.level = %d.\n", - r.in.level, r.out.level); - - } while (ret == True && r.out.level == 7); - - /* } while (ret == True && - r.out.level == 6 && - r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn == r.out.ctr.ctr6.new_highwatermark.highest_usn); - */ - printf("r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn: %llu.\n", - r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn); - printf("r.out.ctr.ctr6.new_highwatermark.highest_usn: %llu.\n", - r.out.ctr.ctr6.new_highwatermark.highest_usn); + if (ret == True && r.out.level == 6) { + DEBUG(0,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y, + r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn, + r.out.ctr.ctr6.new_highwatermark.highest_usn)); + + if (r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn == r.out.ctr.ctr6.new_highwatermark.highest_usn) { + break; + } + } else { + break; + } + } } return ret;
