summaryrefslogtreecommitdiff
path: root/source4/wrepl_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-31 09:44:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:49:33 -0500
commit60d27d8505c483c2fac852d3ddc9148f476dfc6b (patch)
treedca93255ac934f5db62a50b5fa5df00410e926c9 /source4/wrepl_server
parent1d63dc5fe4000de6e3414e3eb45f65f6216cea61 (diff)
downloadsamba-60d27d8505c483c2fac852d3ddc9148f476dfc6b.tar.gz
samba-60d27d8505c483c2fac852d3ddc9148f476dfc6b.tar.bz2
samba-60d27d8505c483c2fac852d3ddc9148f476dfc6b.zip
r12642: only do push notifications when something changed
metze (This used to be commit 61f1c8c347d26f34e3e924ceae55e99e6c1461f7)
Diffstat (limited to 'source4/wrepl_server')
-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;