summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-10-26 13:36:56 +0200
committerVolker Lendecke <vlendec@samba.org>2011-10-27 20:28:31 +0200
commit37d7d523589cfa69220b60a37abbb5aefb11f338 (patch)
treeb6c0682209347e1c54cd9bab5a352d6cedb09dc0
parentba0171f72402d823abc86504c35312a29749f9b2 (diff)
downloadsamba-37d7d523589cfa69220b60a37abbb5aefb11f338.tar.gz
samba-37d7d523589cfa69220b60a37abbb5aefb11f338.tar.bz2
samba-37d7d523589cfa69220b60a37abbb5aefb11f338.zip
s3: Add serverids_exist
-rw-r--r--source3/include/serverid.h5
-rw-r--r--source3/lib/serverid.c34
2 files changed, 39 insertions, 0 deletions
diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index 62bf638214..babb21b8f7 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -44,6 +44,11 @@ bool serverid_register_msg_flags(const struct server_id id, bool do_reg,
bool serverid_exists(const struct server_id *id);
/*
+ * Check existence of a list of server ids
+ */
+bool serverids_exist(const struct server_id *ids, int num_ids, bool *results);
+
+/*
* Walk the list of server_ids registered
*/
bool serverid_traverse(int (*fn)(struct db_record *rec,
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index b3b294f893..274b44b86f 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -273,6 +273,40 @@ bool serverid_exists(const struct server_id *id)
return state.exists;
}
+bool serverids_exist(const struct server_id *ids, int num_ids, bool *results)
+{
+ struct db_context *db;
+ int i;
+
+ if (!processes_exist(ids, num_ids, results)) {
+ return false;
+ }
+
+ db = serverid_db();
+ if (db == NULL) {
+ return false;
+ }
+
+ for (i=0; i<num_ids; i++) {
+ struct serverid_exists_state state;
+ struct serverid_key key;
+ TDB_DATA tdbkey;
+
+ if (!results[i]) {
+ continue;
+ }
+
+ serverid_fill_key(&ids[i], &key);
+ tdbkey = make_tdb_data((uint8_t *)&key, sizeof(key));
+
+ state.id = &ids[i];
+ state.exists = false;
+ dbwrap_parse_record(db, tdbkey, server_exists_parse, &state);
+ results[i] = state.exists;
+ }
+ return true;
+}
+
static bool serverid_rec_parse(const struct db_record *rec,
struct server_id *id, uint32_t *msg_flags)
{