[CRIU] [PATCH 4/4] files: ghost -- Implement clear_ghost_files

Cyrill Gorcunov gorcunov at openvz.org
Thu Sep 4 11:23:38 PDT 2014


It was declared but for some reason missed to
implement. Now since we're carrying dup'ed
descriptors there don't forget to close before
end.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-dump.c   |  1 +
 files-reg.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/cr-dump.c b/cr-dump.c
index a77b636c65ae..334de907ab29 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1915,6 +1915,7 @@ err:
 	free_file_locks();
 	free_link_remaps();
 	free_aufs_branches();
+	clear_ghost_files();
 
 	close_service_fd(CR_PROC_FD_OFF);
 
diff --git a/files-reg.c b/files-reg.c
index 4c3b358c7e7a..10074bf0e7a8 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -267,6 +267,18 @@ struct collect_image_info remap_cinfo = {
 	.collect = collect_one_remap,
 };
 
+void clear_ghost_files(void)
+{
+	struct ghost_file *gf, *tmp;
+
+	list_for_each_entry_safe(gf, tmp, &ghost_files, list) {
+		if (gf->s.lfd >= 0)
+			close(gf->s.lfd);
+		list_del(&gf->list);
+		xfree(gf);
+	}
+}
+
 int dump_ghost_files(void)
 {
 	struct ghost_file *gf;
-- 
1.9.3



More information about the CRIU mailing list