return 0;
}
-int server_id_db_remove(struct server_id_db *db, const char *name)
+int server_id_db_prune_name(struct server_id_db *db, const char *name,
+ struct server_id server)
{
struct tdb_context *tdb = db->tdb->tdb;
struct server_id_buf buf;
TDB_DATA key;
uint8_t *data;
- char *ids, *n, *id;
+ char *ids, *id;
int ret;
- n = strv_find(db->names, name);
- if (n == NULL) {
- return ENOENT;
- }
-
key = string_term_tdb_data(name);
- server_id_str_buf(db->pid, &buf);
+ server_id_str_buf(server, &buf);
ret = tdb_chainlock(tdb, key);
if (ret == -1) {
tdb_chainunlock(tdb, key);
- if (ret == -1) {
- enum TDB_ERROR err = tdb_error(tdb);
- return map_unix_error_from_tdb(err);
+ return 0;
+}
+
+int server_id_db_remove(struct server_id_db *db, const char *name)
+{
+ char *n;
+ int ret;
+
+ n = strv_find(db->names, name);
+ if (n == NULL) {
+ return ENOENT;
+ }
+
+ ret = server_id_db_prune_name(db, name, db->pid);
+ if (ret != 0) {
+ return ret;
}
strv_delete(&db->names, n);
void server_id_db_reinit(struct server_id_db *db, struct server_id pid);
int server_id_db_add(struct server_id_db *db, const char *name);
int server_id_db_remove(struct server_id_db *db, const char *name);
+int server_id_db_prune_name(struct server_id_db *db, const char *name,
+ struct server_id server);
int server_id_db_lookup(struct server_id_db *db, const char *name,
TALLOC_CTX *mem_ctx, unsigned *num_servers,
struct server_id **servers);