summaryrefslogtreecommitdiff
path: root/source4/wrepl_server
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-11-08 00:11:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:53 -0500
commit5c9590587197dcb95007fdc54318187d5716c7c6 (patch)
treed5161aa628d8a4bc4f11bf849d76a451ff44522c /source4/wrepl_server
parent14b59bcbec1a288810efee5c9442dff30f1a474a (diff)
downloadsamba-5c9590587197dcb95007fdc54318187d5716c7c6.tar.gz
samba-5c9590587197dcb95007fdc54318187d5716c7c6.tar.bz2
samba-5c9590587197dcb95007fdc54318187d5716c7c6.zip
r11567: Ldb API change patch.
This patch changes the way lsb_search is called and the meaning of the returned integer. The last argument of ldb_search is changed from struct ldb_message to struct ldb_result which contains a pointer to a struct ldb_message list and a count of the number of messages. The return is not the count of messages anymore but instead it is an ldb error value. I tryed to keep the patch as tiny as possible bu as you can guess I had to change a good amount of places. I also tried to double check all my changes being sure that the calling functions would still behave as before. But this patch is big enough that I fear some bug may have been introduced anyway even if it passes the test suite. So if you are currently working on any file being touched please give it a deep look and blame me for any error. Simo. (This used to be commit 22c8c97e6fb466b41859e090e959d7f1134be780)
Diffstat (limited to 'source4/wrepl_server')
-rw-r--r--source4/wrepl_server/wrepl_in_call.c21
-rw-r--r--source4/wrepl_server/wrepl_server.c61
2 files changed, 38 insertions, 44 deletions
diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c
index 7ccb52cc20..38d0b72405 100644
--- a/source4/wrepl_server/wrepl_in_call.c
+++ b/source4/wrepl_server/wrepl_in_call.c
@@ -35,6 +35,7 @@
#include "libcli/composite/composite.h"
#include "nbt_server/wins/winsdb.h"
#include "lib/ldb/include/ldb.h"
+#include "lib/ldb/include/ldb_errors.h"
static NTSTATUS wreplsrv_in_start_association(struct wreplsrv_in_call *call)
{
@@ -185,7 +186,7 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call)
struct wreplsrv_owner local_owner;
struct wreplsrv_owner *owner;
const char *filter;
- struct ldb_message **res = NULL;
+ struct ldb_result *res = NULL;
int ret;
struct wrepl_wins_name *names;
struct winsdb_record *rec;
@@ -240,28 +241,26 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call)
owner_in->min_version, owner_in->max_version);
NT_STATUS_HAVE_NO_MEMORY(filter);
ret = ldb_search(service->wins_db, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res);
- if (res != NULL) {
- talloc_steal(call, res);
- }
- if (ret < 0) return NT_STATUS_INTERNAL_DB_CORRUPTION;
- if (ret == 0) {
+ if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ talloc_steal(call, res);
+ if (res->count == 0) {
DEBUG(2,("WINSREPL:reply [%u] records owner[%s] min[%llu] max[%llu] to partner[%s]\n",
- ret, owner_in->address, owner_in->min_version, owner_in->max_version,
+ res->count, owner_in->address, owner_in->min_version, owner_in->max_version,
call->wreplconn->partner->address));
return NT_STATUS_OK;
}
- names = talloc_array(call, struct wrepl_wins_name, ret);
+ names = talloc_array(call, struct wrepl_wins_name, res->count);
NT_STATUS_HAVE_NO_MEMORY(names);
- for (i=0; i < ret; i++) {
- status = winsdb_record(res[i], NULL, call, &rec);
+ for (i = 0; i < res->count; i++) {
+ status = winsdb_record(res->msgs[i], NULL, call, &rec);
NT_STATUS_NOT_OK_RETURN(status);
status = wreplsrv_record2wins_name(names, call->wreplconn->our_ip, &names[i], rec);
NT_STATUS_NOT_OK_RETURN(status);
talloc_free(rec);
- talloc_free(res[i]);
+ talloc_free(res->msgs[i]);
}
/* sort the names before we send them */
diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c
index e49b5879dc..8249e6ac31 100644
--- a/source4/wrepl_server/wrepl_server.c
+++ b/source4/wrepl_server/wrepl_server.c
@@ -31,6 +31,7 @@
#include "wrepl_server/wrepl_server.h"
#include "nbt_server/wins/winsdb.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
/*
open winsdb
@@ -63,7 +64,7 @@ struct wreplsrv_partner *wreplsrv_find_partner(struct wreplsrv_service *service,
*/
static NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service)
{
- struct ldb_message **res = NULL;
+ struct ldb_result *res = NULL;
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(service);
int i;
@@ -71,29 +72,27 @@ static NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service)
/* find the record in the WINS database */
ret = ldb_search(service->wins_db, ldb_dn_explode(tmp_ctx, "CN=PARTNERS"), LDB_SCOPE_ONELEVEL,
"(objectClass=wreplPartner)", NULL, &res);
- if (res != NULL) {
- talloc_steal(tmp_ctx, res);
- }
- if (ret < 0) goto failed;
- if (ret == 0) goto done;
+ if (ret != LDB_SUCCESS) goto failed;
+ talloc_steal(tmp_ctx, res);
+ if (res->count == 0) goto done;
- for (i=0; i < ret; i++) {
+ for (i=0; i < res->count; i++) {
struct wreplsrv_partner *partner;
partner = talloc_zero(service, struct wreplsrv_partner);
if (partner == NULL) goto failed;
- partner->service = service;
- partner->address = ldb_msg_find_string(res[i], "address", NULL);
+ partner->service = service;
+ partner->address = ldb_msg_find_string(res->msgs[i], "address", NULL);
if (!partner->address) goto failed;
- partner->name = ldb_msg_find_string(res[i], "name", partner->address);
- partner->type = ldb_msg_find_uint(res[i], "type", WINSREPL_PARTNER_BOTH);
- partner->pull.interval = ldb_msg_find_uint(res[i], "pullInterval",
+ partner->name = ldb_msg_find_string(res->msgs[i], "name", partner->address);
+ partner->type = ldb_msg_find_uint(res->msgs[i], "type", WINSREPL_PARTNER_BOTH);
+ partner->pull.interval = ldb_msg_find_uint(res->msgs[i], "pullInterval",
WINSREPL_DEFAULT_PULL_INTERVAL);
- partner->pull.retry_interval = ldb_msg_find_uint(res[i], "pullRetryInterval",
+ partner->pull.retry_interval = ldb_msg_find_uint(res->msgs[i], "pullRetryInterval",
WINSREPL_DEFAULT_PULL_RETRY_INTERVAL);
- partner->our_address = ldb_msg_find_string(res[i], "ourAddress", NULL);
- partner->push.change_count = ldb_msg_find_uint(res[i], "pushChangeCount",
+ partner->our_address = ldb_msg_find_string(res->msgs[i], "ourAddress", NULL);
+ partner->push.change_count = ldb_msg_find_uint(res->msgs[i], "pushChangeCount",
WINSREPL_DEFAULT_PUSH_CHANGE_COUNT);
talloc_steal(partner, partner->address);
@@ -138,7 +137,7 @@ uint64_t wreplsrv_local_max_version(struct wreplsrv_service *service)
int ret;
struct ldb_context *ldb = service->wins_db;
struct ldb_dn *dn;
- struct ldb_message **res = NULL;
+ struct ldb_result *res = NULL;
TALLOC_CTX *tmp_ctx = talloc_new(service);
uint64_t maxVersion = 0;
@@ -148,14 +147,12 @@ uint64_t wreplsrv_local_max_version(struct wreplsrv_service *service)
/* find the record in the WINS database */
ret = ldb_search(ldb, dn, LDB_SCOPE_BASE,
NULL, NULL, &res);
- if (res != NULL) {
- talloc_steal(tmp_ctx, res);
- }
- if (ret < 0) goto failed;
- if (ret > 1) goto failed;
+ if (ret != LDB_SUCCESS) goto failed;
+ talloc_steal(tmp_ctx, res);
+ if (res->count > 1) goto failed;
- if (ret == 1) {
- maxVersion = ldb_msg_find_uint64(res[0], "maxVersion", 0);
+ if (res->count == 1) {
+ maxVersion = ldb_msg_find_uint64(res->msgs[0], "maxVersion", 0);
}
failed:
@@ -268,7 +265,7 @@ NTSTATUS wreplsrv_add_table(struct wreplsrv_service *service,
*/
static NTSTATUS wreplsrv_load_table(struct wreplsrv_service *service)
{
- struct ldb_message **res = NULL;
+ struct ldb_result *res = NULL;
int ret;
NTSTATUS status;
TALLOC_CTX *tmp_ctx = talloc_new(service);
@@ -284,16 +281,14 @@ static NTSTATUS wreplsrv_load_table(struct wreplsrv_service *service)
/* find the record in the WINS database */
ret = ldb_search(service->wins_db, NULL, LDB_SCOPE_SUBTREE,
"(objectClass=winsRecord)", attrs, &res);
- if (res != NULL) {
- talloc_steal(tmp_ctx, res);
- }
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
- if (ret < 0) goto failed;
- if (ret == 0) goto done;
+ if (ret != LDB_SUCCESS) goto failed;
+ talloc_steal(tmp_ctx, res);
+ if (res->count == 0) goto done;
- for (i=0; i < ret; i++) {
- wins_owner = ldb_msg_find_string(res[i], "winsOwner", NULL);
- version = ldb_msg_find_uint64(res[i], "versionID", 0);
+ for (i=0; i < res->count; i++) {
+ wins_owner = ldb_msg_find_string(res->msgs[i], "winsOwner", NULL);
+ version = ldb_msg_find_uint64(res->msgs[i], "versionID", 0);
if (wins_owner) {
status = wreplsrv_add_table(service,
@@ -301,7 +296,7 @@ static NTSTATUS wreplsrv_load_table(struct wreplsrv_service *service)
wins_owner, version);
if (!NT_STATUS_IS_OK(status)) goto failed;
}
- talloc_free(res[i]);
+ talloc_free(res->msgs[i]);
/* TODO: what's abut the per address owners? */
}