[CRIU] [PATCH 02/21] pipes: Make pipes_with_data being static

Cyrill Gorcunov gorcunov at openvz.org
Wed Jun 6 18:21:42 EDT 2012


There is no need to make it xmalloc'ed, it's
global for all processes dumped.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-dump.c       |    4 ----
 include/pipes.h |    2 --
 pipes.c         |   18 +++---------------
 3 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index d88537f..94ff67a 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1718,9 +1718,6 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
 	if (init_shmem_dump())
 		goto err;
 
-	if (init_pipes_dump())
-		goto err;
-
 	for_each_pstree_item(item) {
 		if (dump_one_task(item))
 			goto err;
@@ -1740,7 +1737,6 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
 	fd_id_show_tree();
 err:
 	fini_shmem_dump();
-	fini_pipes_dump();
 	close_cr_fdset(&glob_fdset);
 
 	/*
diff --git a/include/pipes.h b/include/pipes.h
index e3bc2fb..67b17a2 100644
--- a/include/pipes.h
+++ b/include/pipes.h
@@ -2,8 +2,6 @@
 #define __CR_PIPES_H__
 extern int collect_pipes(void);
 extern void mark_pipe_master(void);
-int init_pipes_dump(void);
-void fini_pipes_dump(void);
 int dump_pipe(struct fd_parms *p, int lfd,
 			     const struct cr_fdset *cr_fdset);
 #endif
diff --git a/pipes.c b/pipes.c
index 547fdf8..5e30528 100644
--- a/pipes.c
+++ b/pipes.c
@@ -300,9 +300,8 @@ static int open_pipe(struct file_desc *d)
 	return tmp;
 }
 
-#define PIPES_SIZE 1024
-static u32 *pipes_with_data;	/* pipes for which data already dumped */
-static int nr_pipes = 0;
+static u32 pipes_with_data[1024];	/* pipes for which data already dumped */
+static int nr_pipes;
 
 static int dump_one_pipe_data(int lfd, u32 id, const struct fd_parms *p)
 {
@@ -321,7 +320,7 @@ static int dump_one_pipe_data(int lfd, u32 id, const struct fd_parms *p)
 
 	pr_info("Dumping data from pipe %#x fd %d\n", id, lfd);
 
-	if (PIPES_SIZE < nr_pipes + 1) {
+	if (ARRAY_SIZE(pipes_with_data) < nr_pipes + 1) {
 		pr_err("OOM storing pipe\n");
 		return -1;
 	}
@@ -424,14 +423,3 @@ int dump_pipe(struct fd_parms *p, int lfd,
 {
 	return do_dump_gen_file(p, lfd, &pipe_ops, cr_fdset);
 }
-
-int init_pipes_dump(void)
-{
-	pipes_with_data = xmalloc(PIPES_SIZE * sizeof(*pipes_with_data));
-	return pipes_with_data == NULL ? -1 : 0;
-}
-
-void fini_pipes_dump(void)
-{
-	xfree(pipes_with_data);
-}
-- 
1.7.7.6



More information about the CRIU mailing list