summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2015-04-26 11:02:27 +0200
committerJeremy Allison <jra@samba.org>2015-07-07 23:51:23 +0200
commitb593cc78aeaaa5d79ddfccc46bdbac6296a63890 (patch)
treed68b3e2e8f81c9399f37f9edde99196b7142fd11 /lib
parent07c9f697692c784af1f5ab254c1638c60dec407f (diff)
downloadsamba-b593cc78aeaaa5d79ddfccc46bdbac6296a63890.tar.gz
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/util/server_id_db.c31
-rw-r--r--lib/util/server_id_db.h2
2 files changed, 22 insertions, 11 deletions
diff --git a/lib/util/server_id_db.c b/lib/util/server_id_db.c
index 7f5b055f171..83547525188 100644
--- a/lib/util/server_id_db.c
+++ b/lib/util/server_id_db.c
@@ -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);
diff --git a/lib/util/server_id_db.h b/lib/util/server_id_db.h
index 31b3305f471..ff864360409 100644
--- a/lib/util/server_id_db.h
+++ b/lib/util/server_id_db.h
@@ -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);