mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
lib: Add server_id_db_prune_name
With this you can remove a foreign mapping. Required to clean up dead processes. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
07c9f69769
commit
b593cc78ae
@ -118,22 +118,18 @@ int server_id_db_add(struct server_id_db *db, const char *name)
|
||||
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) {
|
||||
@ -162,9 +158,22 @@ int server_id_db_remove(struct server_id_db *db, const char *name)
|
||||
|
||||
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);
|
||||
|
@ -32,6 +32,8 @@ struct server_id_db *server_id_db_init(TALLOC_CTX *mem_ctx,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user