summaryrefslogtreecommitdiffstats
path: root/src/responder/autofs/autofssrv_cmd.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-12-15 13:23:09 +0100
committerJakub Hrozek <jhrozek@redhat.com>2012-12-18 20:03:27 +0100
commit460ccce18abc25db8ebe230111b1e5303999b8d3 (patch)
tree04d5d5aebc155a8257ca5786f88040495b1efcd4 /src/responder/autofs/autofssrv_cmd.c
parentcf308d76dbd0ed95f00ed1e998b3f1d52f7f8e6b (diff)
downloadsssd-460ccce18abc25db8ebe230111b1e5303999b8d3.tar.gz
sssd-460ccce18abc25db8ebe230111b1e5303999b8d3.tar.xz
sssd-460ccce18abc25db8ebe230111b1e5303999b8d3.zip
AUTOFS: allow removing entries from hash table
There is a timed desctructor in the autofs responder that, when the entry timeout passes, removes the autofs map from the hash table while the map is freed. This patch adds a hash delete callback so that if the map is removed from the hash table with hash_delete, its hash table pointer will be invalidated. Later, when the entry is being freed, the destructor won't attempt to remove it from the hash table.
Diffstat (limited to 'src/responder/autofs/autofssrv_cmd.c')
-rw-r--r--src/responder/autofs/autofssrv_cmd.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/responder/autofs/autofssrv_cmd.c b/src/responder/autofs/autofssrv_cmd.c
index 3af4a8468..0cfdbec59 100644
--- a/src/responder/autofs/autofssrv_cmd.c
+++ b/src/responder/autofs/autofssrv_cmd.c
@@ -118,6 +118,27 @@ get_autofs_map(struct autofs_ctx *actx,
static int autofs_map_hash_remove (TALLOC_CTX *ctx);
+void
+autofs_map_hash_delete_cb(hash_entry_t *item,
+ hash_destroy_enum deltype, void *pvt)
+{
+ struct autofs_map_ctx *map;
+
+ if (deltype != HASH_ENTRY_DESTROY) {
+ return;
+ }
+
+ map = talloc_get_type(item->value.ptr, struct autofs_map_ctx);
+ if (!map) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Invalid autofs map\n"));
+ return;
+ }
+
+ /* So that the destructor wouldn't attempt to remove the map from hash
+ * table */
+ map->map_table = NULL;
+}
+
static errno_t
set_autofs_map(struct autofs_ctx *actx,
struct autofs_map_ctx *map)
@@ -158,6 +179,12 @@ autofs_map_hash_remove(TALLOC_CTX *ctx)
struct autofs_map_ctx *map =
talloc_get_type(ctx, struct autofs_map_ctx);
+ if (map->map_table == NULL) {
+ DEBUG(SSSDBG_TRACE_LIBS, ("autofs map [%s] was already removed\n",
+ map->mapname));
+ return 0;
+ }
+
key.type = HASH_KEY_STRING;
key.str = map->mapname;