summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/wrepl_server/wrepl_out_push.c26
-rw-r--r--source4/wrepl_server/wrepl_server.c28
-rw-r--r--source4/wrepl_server/wrepl_server.h3
3 files changed, 53 insertions, 4 deletions
diff --git a/source4/wrepl_server/wrepl_out_push.c b/source4/wrepl_server/wrepl_out_push.c
index 6ac04d9f12..82e6031564 100644
--- a/source4/wrepl_server/wrepl_out_push.c
+++ b/source4/wrepl_server/wrepl_out_push.c
@@ -96,17 +96,35 @@ nomem:
return;
}
-static uint32_t wreplsrv_calc_change_count(struct wreplsrv_partner *partner)
+static uint32_t wreplsrv_calc_change_count(struct wreplsrv_partner *partner, uint64_t seqnumber)
{
- /* TODO: add a real implementation here */
- return (uint32_t)-1;
+ uint64_t tmp_diff = UINT32_MAX;
+
+ /* catch an overflow */
+ if (partner->push.seqnumber > seqnumber) {
+ goto done;
+ }
+
+ tmp_diff = seqnumber - partner->push.seqnumber;
+
+ if (tmp_diff > UINT32_MAX) {
+ tmp_diff = UINT32_MAX;
+ goto done;
+ }
+
+done:
+ partner->push.seqnumber = seqnumber;
+ return (uint32_t)(tmp_diff & UINT32_MAX);
}
NTSTATUS wreplsrv_out_push_run(struct wreplsrv_service *service)
{
struct wreplsrv_partner *partner;
+ uint64_t seqnumber;
uint32_t change_count;
+ seqnumber = wreplsrv_local_db_seqnumber(service);
+
for (partner = service->partners; partner; partner = partner->next) {
/* if it's not a push partner, go to the next partner */
if (!(partner->type & WINSREPL_PARTNER_PUSH)) continue;
@@ -115,7 +133,7 @@ NTSTATUS wreplsrv_out_push_run(struct wreplsrv_service *service)
if (partner->push.change_count == 0) continue;
/* get the actual change count for the partner */
- change_count = wreplsrv_calc_change_count(partner);
+ change_count = wreplsrv_calc_change_count(partner, seqnumber);
/* if the configured change count isn't reached, go to the next partner */
if (change_count < partner->push.change_count) continue;
diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c
index 9f1664bc22..018b137d7e 100644
--- a/source4/wrepl_server/wrepl_server.c
+++ b/source4/wrepl_server/wrepl_server.c
@@ -197,6 +197,34 @@ failed:
return maxVersion;
}
+uint64_t wreplsrv_local_db_seqnumber(struct wreplsrv_service *service)
+{
+ int ret;
+ struct ldb_context *ldb = service->wins_db->ldb;
+ struct ldb_dn *dn;
+ struct ldb_result *res = NULL;
+ TALLOC_CTX *tmp_ctx = talloc_new(service);
+ uint64_t seqnumber = 0;
+
+ dn = ldb_dn_explode(tmp_ctx, "@BASEINFO");
+ if (!dn) goto failed;
+
+ /* find the record in the WINS database */
+ ret = ldb_search(ldb, dn, LDB_SCOPE_BASE,
+ NULL, NULL, &res);
+ if (ret != LDB_SUCCESS) goto failed;
+ talloc_steal(tmp_ctx, res);
+ if (res->count > 1) goto failed;
+
+ if (res->count == 1) {
+ seqnumber = ldb_msg_find_uint64(res->msgs[0], "sequenceNumber", 0);
+ }
+
+failed:
+ talloc_free(tmp_ctx);
+ return seqnumber;
+}
+
NTSTATUS wreplsrv_fill_wrepl_table(struct wreplsrv_service *service,
TALLOC_CTX *mem_ctx,
struct wrepl_table *table_out,
diff --git a/source4/wrepl_server/wrepl_server.h b/source4/wrepl_server/wrepl_server.h
index 48378fe152..c846e08d64 100644
--- a/source4/wrepl_server/wrepl_server.h
+++ b/source4/wrepl_server/wrepl_server.h
@@ -172,6 +172,9 @@ struct wreplsrv_partner {
/* change count till push notification */
uint32_t change_count;
+ /* the last wins db seqnumber we know about */
+ uint64_t seqnumber;
+
/* we should use WREPL_REPL_INFORM* messages to this partner */
BOOL use_inform;