代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/lxcfs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From a7f9759ef8ce354ab2ad420d4a8c5b4260d491fc Mon Sep 17 00:00:00 2001
From: vegbir <[email protected]>
Date: Thu, 27 Jul 2023 07:24:18 +0000
Subject: [PATCH 05/15] fix concurrency problem
Signed-off-by: vegbir <[email protected]>
---
src/cgroups/cgroup_utils.c | 21 +++++++++++++--------
src/cgroups/cgroup_utils.h | 2 +-
src/proc_fuse.c | 3 +++
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/cgroups/cgroup_utils.c b/src/cgroups/cgroup_utils.c
index 83e4cbf..1224971 100644
--- a/src/cgroups/cgroup_utils.c
+++ b/src/cgroups/cgroup_utils.c
@@ -512,23 +512,28 @@ static char *copy_to_eol(char *p)
return sret;
}
-static void batch_realloc(char **mem, size_t oldlen, size_t newlen)
+char *batch_realloc(char *mem, size_t oldlen, size_t newlen)
{
int newbatches = (newlen / BATCH_SIZE) + 1;
int oldbatches = (oldlen / BATCH_SIZE) + 1;
- if (!*mem || newbatches > oldbatches) {
- *mem = must_realloc(*mem, newbatches * BATCH_SIZE);
+ if (!mem || newbatches > oldbatches) {
+ char *tmp;
+ tmp = must_realloc(mem, newbatches * BATCH_SIZE);
+ return tmp;
}
+ return mem;
}
-void append_line(char **dest, size_t oldlen, char *new, size_t newlen)
+char *append_line(char *dest, size_t oldlen, char *new, size_t newlen)
{
+ char *tmp;
size_t full = oldlen + newlen;
- batch_realloc(dest, oldlen, full + 1);
+ tmp = batch_realloc(dest, oldlen, full + 1);
- memcpy(*dest + oldlen, new, newlen + 1);
+ memcpy(tmp + oldlen, new, newlen + 1);
+ return tmp;
}
static inline void drop_trailing_newlines(char *s)
@@ -552,7 +557,7 @@ char *read_file(const char *fnam)
if (!f)
return NULL;
while ((linelen = getline(&line, &len, f)) != -1) {
- append_line(&buf, fulllen, line, linelen);
+ buf = append_line(buf, fulllen, line, linelen);
fulllen += linelen;
}
return buf;
@@ -682,7 +687,7 @@ char *readat_file(int dirfd, const char *path)
move_fd(fd);
while ((linelen = getline(&line, &len, f)) != -1) {
- append_line(&buf, fulllen, line, linelen);
+ buf = append_line(buf, fulllen, line, linelen);
fulllen += linelen;
}
diff --git a/src/cgroups/cgroup_utils.h b/src/cgroups/cgroup_utils.h
index f431686..d4c8598 100644
--- a/src/cgroups/cgroup_utils.h
+++ b/src/cgroups/cgroup_utils.h
@@ -70,7 +70,7 @@ extern size_t strlcat(char *d, const char *s, size_t n);
#endif
extern FILE *fopen_cloexec(const char *path, const char *mode);
-extern void append_line(char **dest, size_t oldlen, char *new, size_t newlen);
+extern char *append_line(char *dest, size_t oldlen, char *new, size_t newlen);
extern char *read_file(const char *fnam);
extern char *readat_file(int fd, const char *path);
extern char *read_file_strip_newline(const char *fnam);
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index ed70ea7..0af559f 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -1747,6 +1747,9 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size,
{
struct file_info *f = INTTYPE_TO_PTR(fi->fh);
+ if (!f->buf)
+ return -EINVAL;
+
switch (f->type) {
case LXC_TYPE_PROC_MEMINFO:
if (liblxcfs_functional())
--
2.41.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。