summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-08-23 09:03:36 +0200
committerStefan Metzmacher <metze@samba.org>2012-08-24 13:43:33 +0200
commit18c6757dbb7ee0e6a4be15b0f2a3fec1f94ba518 (patch)
tree6486a2671848956f57de058c7745e9c2cc9a142f
parent6c3c25b5c1e4981687556b7a8e56c8460d69deb4 (diff)
downloadsamba-18c6757dbb7ee0e6a4be15b0f2a3fec1f94ba518.tar.gz
s3:lib: only loop over the server_ids we need to verify in serverids_exist()
metze
-rw-r--r--source3/lib/serverid.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index 61860977cf1..3392e83c89a 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -270,6 +270,8 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results)
int todo_num = 0;
int *remote_idx = NULL;
int remote_num = 0;
+ int *verify_idx = NULL;
+ int verify_num = 0;
int t, idx;
bool result = false;
struct db_context *db;
@@ -296,6 +298,10 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results)
if (remote_idx == NULL) {
goto fail;
}
+ verify_idx = talloc_array(talloc_tos(), int, num_ids);
+ if (verify_idx == NULL) {
+ goto fail;
+ }
for (idx=0; idx<num_ids; idx++) {
results[idx] = false;
@@ -316,7 +322,13 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results)
continue;
}
- results[idx] = true;
+ if (ids[idx].unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+ results[idx] = true;
+ continue;
+ }
+
+ verify_idx[verify_num] = idx;
+ verify_num += 1;
continue;
}
@@ -354,24 +366,23 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results)
continue;
}
- results[idx] = true;
+ if (ids[idx].unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+ results[idx] = true;
+ continue;
+ }
+
+ verify_idx[verify_num] = idx;
+ verify_num += 1;
}
}
- for (idx=0; idx<num_ids; idx++) {
+ for (t=0; t<verify_num; t++) {
struct serverid_exists_state state;
struct serverid_key key;
TDB_DATA tdbkey;
NTSTATUS status;
- if (!results[idx]) {
- continue;
- }
-
- if (ids[idx].unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
- results[idx] = true;
- continue;
- }
+ idx = verify_idx[t];
serverid_fill_key(&ids[idx], &key);
tdbkey = make_tdb_data((uint8_t *)&key, sizeof(key));
@@ -388,6 +399,7 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results)
result = true;
fail:
+ TALLOC_FREE(verify_idx);
TALLOC_FREE(remote_idx);
TALLOC_FREE(todo_results);
TALLOC_FREE(todo_ids);