diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-01-21 08:53:56 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:51:20 -0500 |
commit | f25ad21617d7887d68bff3cad31045e8a98e3cae (patch) | |
tree | 21df9971bb1decb522c5f6b1122e45c610ee62f3 /source4/wrepl_server/wrepl_in_call.c | |
parent | b19ca85e97bf1eddaa944655b66dadd428688d7e (diff) | |
download | samba-f25ad21617d7887d68bff3cad31045e8a98e3cae.tar.gz |
r13060: - return only active addresses in name query responses
- replicate only active addresses
metze
(This used to be commit 6325abd95c5df855e8d1de2be9745940a29ba00a)
Diffstat (limited to 'source4/wrepl_server/wrepl_in_call.c')
-rw-r--r-- | source4/wrepl_server/wrepl_in_call.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c index 3365a1f146e..8ce88db6a9c 100644 --- a/source4/wrepl_server/wrepl_in_call.c +++ b/source4/wrepl_server/wrepl_in_call.c @@ -30,6 +30,7 @@ #include "nbt_server/wins/winsdb.h" #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" +#include "system/time.h" static NTSTATUS wreplsrv_in_start_association(struct wreplsrv_in_call *call) { @@ -178,7 +179,8 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) struct wrepl_wins_name *names; struct winsdb_record *rec; NTSTATUS status; - uint32_t i; + uint32_t i, j; + time_t now = time(NULL); owner = wreplsrv_find_owner(service, service->table, owner_in->address); @@ -258,26 +260,37 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) names = talloc_array(call, struct wrepl_wins_name, res->count); NT_STATUS_HAVE_NO_MEMORY(names); - for (i = 0; i < res->count; i++) { - status = winsdb_record(service->wins_db, res->msgs[i], call, &rec); + for (i=0, j=0; i < res->count; i++) { + status = winsdb_record(service->wins_db, res->msgs[i], call, now, &rec); NT_STATUS_NOT_OK_RETURN(status); - status = wreplsrv_record2wins_name(names, &names[i], rec); - NT_STATUS_NOT_OK_RETURN(status); + /* + * it's possible that winsdb_record() made the record RELEASED + * because it's expired, but in the database it's still stored + * as ACTIVE... + * + * make sure we really only replicate ACTIVE and TOMBSTONE records + */ + if (rec->state == WREPL_STATE_ACTIVE || rec->state == WREPL_STATE_TOMBSTONE) { + status = wreplsrv_record2wins_name(names, &names[j], rec); + NT_STATUS_NOT_OK_RETURN(status); + j++; + } + talloc_free(rec); talloc_free(res->msgs[i]); } /* sort the names before we send them */ - qsort(names, res->count, sizeof(struct wrepl_wins_name), (comparison_fn_t)wreplsrv_in_sort_wins_name); + qsort(names, j, sizeof(struct wrepl_wins_name), (comparison_fn_t)wreplsrv_in_sort_wins_name); DEBUG(2,("WINSREPL:reply [%u] records owner[%s] min[%llu] max[%llu] to partner[%s]\n", - res->count, owner_in->address, + j, owner_in->address, (long long)owner_in->min_version, (long long)owner_in->max_version, call->wreplconn->partner->address)); - reply_out->num_names = res->count; + reply_out->num_names = j; reply_out->names = names; return NT_STATUS_OK; |