From: tomponline Date: Fri, 18 Jan 2019 13:05:09 +0000 (+0000) Subject: bindings: protect do_release_file_info() with mutex X-Git-Tag: lxcfs-3.1.0~11^2 X-Git-Url: https://git.proxmox.com/?p=mirror_lxcfs.git;a=commitdiff_plain;h=0108dc1cc6eab76392d228ee4ca844729096473d bindings: protect do_release_file_info() with mutex Add a mutex to do_release_file_info to avoid lxcfs crash when stopping multiple containers concurrently Signed-off-by: tomponline [christian.brauner@ubuntu.com: use correct commit message style] Signed-off-by: Christian Brauner --- diff --git a/bindings.c b/bindings.c index 097ca81..29855d5 100644 --- a/bindings.c +++ b/bindings.c @@ -2169,11 +2169,16 @@ out: return ret; } +static pthread_mutex_t do_release_file_info_lock = PTHREAD_MUTEX_INITIALIZER; + static void do_release_file_info(struct fuse_file_info *fi) { + lock_mutex(&do_release_file_info_lock); + struct file_info *f = (struct file_info *)fi->fh; if (!f) + unlock_mutex(&do_release_file_info_lock); return; fi->fh = 0; @@ -2188,6 +2193,8 @@ static void do_release_file_info(struct fuse_file_info *fi) f->buf = NULL; free(f); f = NULL; + + unlock_mutex(&do_release_file_info_lock); } int cg_releasedir(const char *path, struct fuse_file_info *fi)