1 Star 0 Fork 9

zhangsong234/lxcfs

forked from src-openEuler/lxcfs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0008-fix-hang.patch 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
wangkang101 提交于 2020-08-28 15:17 . update to 4.0.5
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 334f6ea..3ceba73 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -51,6 +51,26 @@
#include "proc_cpuview.h"
#include "utils.h"
+static pthread_mutex_t container_dev_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static void lock_mutex(pthread_mutex_t *l)
+{
+ int ret;
+
+ ret = pthread_mutex_lock(l);
+ if (ret)
+ log_exit("%s - returned %d\n", strerror(ret), ret);
+}
+
+static void unlock_mutex(pthread_mutex_t *l)
+{
+ int ret;
+
+ ret = pthread_mutex_unlock(l);
+ if (ret)
+ log_exit("%s - returned %d\n", strerror(ret), ret);
+}
+
struct memory_stat {
uint64_t hierarchical_memory_limit;
uint64_t hierarchical_memsw_limit;
@@ -418,6 +438,16 @@ struct devinfo* container_dev_read(pid_t pid) {
return head;
}
if (child_pid == 0) {
+ /* Disallow signal reception in child process */
+ sigset_t oldset;
+ sigset_t newset;
+ sigemptyset(&newset);
+ sigaddset(&newset, SIGTERM);
+ sigaddset(&newset, SIGINT);
+ sigaddset(&newset, SIGHUP);
+ sigaddset(&newset, SIGQUIT);
+ sigprocmask(SIG_BLOCK,&newset,&oldset);
+
close(mypipe[0]);
stream = fdopen(mypipe[1], "w");
if (stream == NULL) {
@@ -464,6 +494,8 @@ child_out:
lxcfs_error("Error opening pipe for reading: %s\n", strerror(errno));
goto err;
}
+ wait_for_pid(child_pid);
+ child_pid = 0;
while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) {
if (dev_num == 0) {
break;
@@ -590,7 +622,9 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
if (!f)
return 0;
+ lock_mutex(&container_dev_mutex);
container_devinfo = container_dev_read(initpid);
+ unlock_mutex(&container_dev_mutex);
while (getline(&line, &linelen, f) != -1) {
ssize_t l;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangsong234/lxcfs.git
[email protected]:zhangsong234/lxcfs.git
zhangsong234
lxcfs
lxcfs
master

搜索帮助