[CRIU] [PATCH RFC 3/3] files: Allow postponed fdinfo callbacks
Kirill Tkhai
ktkhai at virtuozzo.com
Sun Jul 31 05:43:41 PDT 2016
Unix sockets need postponed .post_open() to close some task sockets
after all other sockets have executed their .post_open() method.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/files.c | 15 ++++++++++++++-
criu/include/files.h | 2 ++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/criu/files.c b/criu/files.c
index 51556c9..286f553 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1096,11 +1096,24 @@ static int open_fdinfos(int pid, struct list_head *list, int state)
{
int ret = 0;
struct fdinfo_list_entry *fle;
+ LIST_HEAD(postpone);
list_for_each_entry(fle, list, ps_list) {
ret = open_fdinfo(pid, fle, state);
- if (ret)
+ if (ret == FDO_ERROR)
break;
+ if (ret == FDO_REPEAT)
+ list_add(&fle->postpone, &postpone);
+ }
+
+ list_for_each_entry(fle, &postpone, postpone) {
+ ret = open_fdinfo(pid, fle, state);
+ if (ret == FDO_ERROR)
+ break;
+ if (ret == FDO_REPEAT) {
+ pr_err("Twice postponed fle\n");
+ break;
+ }
}
return ret;
diff --git a/criu/include/files.h b/criu/include/files.h
index 19ee26a..136ca7c 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -69,6 +69,7 @@ struct fdinfo_list_entry {
struct file_desc *desc; /* Associated file descriptor */
struct list_head ps_list; /* To chain per-task files */
struct list_head used_list; /* To chain per-task used fds */
+ struct list_head postpone; /* To chain during open_fdinfos() */
int pid;
futex_t real_pid;
FdinfoEntry *fe;
@@ -82,6 +83,7 @@ static inline int fdinfo_rst_prio(struct fdinfo_list_entry *fd_a, struct fdinfo_
}
#define FDO_ERROR -1
+#define FDO_REPEAT -2
struct file_desc_ops {
/* fd_types from images/fdinfo.proto */
More information about the CRIU
mailing list