[lxc-devel] [lxcfs/master] Adds mutex to do_release_file_info

tomponline on Github lxc-bot at linuxcontainers.org
Fri Jan 18 13:08:34 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 454 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190118/f9f5061f/attachment.bin>
-------------- next part --------------
From d249048b51f4c406a1fd0317c903ac27fe87dbfc Mon Sep 17 00:00:00 2001
From: tomponline <tomp at tomp.uk>
Date: Fri, 18 Jan 2019 13:05:09 +0000
Subject: [PATCH] Adds mutex to do_release_file_info to avoid lxcfs crash when
 stopping multiple containers concurrently

Signed-off-by: tomponline <tomp at tomp.uk>
---
 bindings.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bindings.c b/bindings.c
index 097ca81..29855d5 100644
--- a/bindings.c
+++ b/bindings.c
@@ -2169,11 +2169,16 @@ int cg_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset
 	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)


More information about the lxc-devel mailing list