diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-01-02 18:25:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:49:37 -0500 |
commit | 6fbbd471648e3d436e21a0f4fe2bdb21dbe4376d (patch) | |
tree | 8835aa1b2caba2ca89055d44fc3934b1d773523e /source4/wrepl_server | |
parent | b75ed7d7ac9b3d5beca71926a15cfec5e3a0092c (diff) | |
download | samba-6fbbd471648e3d436e21a0f4fe2bdb21dbe4376d.tar.gz samba-6fbbd471648e3d436e21a0f4fe2bdb21dbe4376d.tar.bz2 samba-6fbbd471648e3d436e21a0f4fe2bdb21dbe4376d.zip |
r12679: create a sperate function to create the 'winsOwner' part of the search filter,
this is to handle the special '0.0.0.0' of old or manual added owned records
metze
(This used to be commit 4c7306608cc3f86c31ed044bc41eda905b64b31f)
Diffstat (limited to 'source4/wrepl_server')
-rw-r--r-- | source4/wrepl_server/wrepl_in_call.c | 9 | ||||
-rw-r--r-- | source4/wrepl_server/wrepl_scavenging.c | 40 |
2 files changed, 41 insertions, 8 deletions
diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c index 4d5fad8a7c..693c87424a 100644 --- a/source4/wrepl_server/wrepl_in_call.c +++ b/source4/wrepl_server/wrepl_in_call.c @@ -174,6 +174,7 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) struct wrepl_replication *repl_out = &call->rep_packet.message.replication; struct wrepl_send_reply *reply_out = &call->rep_packet.message.replication.info.reply; struct wreplsrv_owner *owner; + const char *owner_filter; const char *filter; struct ldb_result *res = NULL; int ret; @@ -232,11 +233,13 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) return NT_STATUS_OK; } + owner_filter = wreplsrv_owner_filter(service, call, owner->owner.address); + NT_STATUS_HAVE_NO_MEMORY(owner_filter); filter = talloc_asprintf(call, - "(&(winsOwner=%s)(objectClass=winsRecord)" + "(&%s(objectClass=winsRecord)" "(|(recordState=%u)(recordState=%u))" "(versionID>=%llu)(versionID<=%llu))", - owner->owner.address, + owner_filter, WREPL_STATE_ACTIVE, WREPL_STATE_TOMBSTONE, (long long)owner_in->min_version, (long long)owner_in->max_version); @@ -244,6 +247,8 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; talloc_steal(call, res); + DEBUG(10,("WINSREPL: filter '%s' count %d\n", filter, res->count)); + if (res->count == 0) { DEBUG(2,("WINSREPL:reply [%u] records owner[%s] min[%llu] max[%llu] to partner[%s]\n", res->count, owner_in->address, diff --git a/source4/wrepl_server/wrepl_scavenging.c b/source4/wrepl_server/wrepl_scavenging.c index 24ef974f2d..2988fb6b22 100644 --- a/source4/wrepl_server/wrepl_scavenging.c +++ b/source4/wrepl_server/wrepl_scavenging.c @@ -28,11 +28,25 @@ #include "ldb/include/ldb_errors.h" #include "system/time.h" +const char *wreplsrv_owner_filter(struct wreplsrv_service *service, + TALLOC_CTX *mem_ctx, + const char *wins_owner) +{ + if (strcmp(wins_owner, service->wins_db->local_owner) == 0) { + return talloc_asprintf(mem_ctx, "(|(winsOwner=%s)(winsOwner=0.0.0.0))", + wins_owner); + } + + return talloc_asprintf(mem_ctx, "(&(winsOwner=%s)(!(winsOwner=0.0.0.0)))", + wins_owner); +} + static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *service, TALLOC_CTX *tmp_mem) { NTSTATUS status; struct winsdb_record *rec = NULL; struct ldb_result *res = NULL; + const char *owner_filter; const char *filter; uint32_t i; int ret; @@ -48,14 +62,18 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi now_timestr = ldb_timestring(tmp_mem, now); NT_STATUS_HAVE_NO_MEMORY(now_timestr); + owner_filter = wreplsrv_owner_filter(service, tmp_mem, + service->wins_db->local_owner); + NT_STATUS_HAVE_NO_MEMORY(owner_filter); filter = talloc_asprintf(tmp_mem, - "(&(winsOwner=%s)(objectClass=winsRecord)" + "(&%s(objectClass=winsRecord)" "(expireTime<=%s)(!(isStatic=1)))", - service->wins_db->local_owner, now_timestr); + owner_filter, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; talloc_steal(tmp_mem, res); + DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); tombstone_extra_time = timeval_add(&service->startup_time, service->config.tombstone_extra_timeout, @@ -141,6 +159,7 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s NTSTATUS status; struct winsdb_record *rec = NULL; struct ldb_result *res = NULL; + const char *owner_filter; const char *filter; uint32_t i; int ret; @@ -156,14 +175,18 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s now_timestr = ldb_timestring(tmp_mem, now); NT_STATUS_HAVE_NO_MEMORY(now_timestr); + owner_filter = wreplsrv_owner_filter(service, tmp_mem, + service->wins_db->local_owner); + NT_STATUS_HAVE_NO_MEMORY(owner_filter); filter = talloc_asprintf(tmp_mem, - "(&(!(winsOwner=%s))(objectClass=winsRecord)" + "(&(!%s)(objectClass=winsRecord)" "(!(recordState=%u))(expireTime<=%s)(!(isStatic=1)))", - service->wins_db->local_owner, WREPL_STATE_ACTIVE, now_timestr); + owner_filter, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; talloc_steal(tmp_mem, res); + DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); tombstone_extra_time = timeval_add(&service->startup_time, service->config.tombstone_extra_timeout, @@ -246,6 +269,7 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi NTSTATUS status; struct winsdb_record *rec = NULL; struct ldb_result *res = NULL; + const char *owner_filter; const char *filter; uint32_t i; int ret; @@ -259,14 +283,18 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi now_timestr = ldb_timestring(tmp_mem, now); NT_STATUS_HAVE_NO_MEMORY(now_timestr); + owner_filter = wreplsrv_owner_filter(service, tmp_mem, + service->wins_db->local_owner); + NT_STATUS_HAVE_NO_MEMORY(owner_filter); filter = talloc_asprintf(tmp_mem, - "(&(!(winsOwner=%s))(objectClass=winsRecord)" + "(&(!%s)(objectClass=winsRecord)" "(recordState=%u)(expireTime<=%s)(!(isStatic=1)))", - service->wins_db->local_owner, WREPL_STATE_ACTIVE, now_timestr); + owner_filter, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; talloc_steal(tmp_mem, res); + DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); for (i=0; i < res->count; i++) { status = winsdb_record(service->wins_db, res->msgs[i], tmp_mem, &rec); |