diff options
-rw-r--r-- | source3/include/serverid.h | 5 | ||||
-rw-r--r-- | source3/lib/serverid.c | 34 |
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) { |