[CRIU] [PATCH RFC 26/30] eventpoll: Make post_open stage may fail

Kirill Tkhai ktkhai at virtuozzo.com
Tue Nov 1 07:34:33 PDT 2016


Currently, it's just an additional check. But later this
will be used.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/eventpoll.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/criu/eventpoll.c b/criu/eventpoll.c
index 0608c43..1184fc2 100644
--- a/criu/eventpoll.c
+++ b/criu/eventpoll.c
@@ -21,6 +21,7 @@
 #include "image.h"
 #include "util.h"
 #include "log.h"
+#include "pstree.h"
 
 #include "protobuf.h"
 #include "images/eventpoll.pb-c.h"
@@ -143,6 +144,19 @@ static int eventpoll_open(struct file_desc *d)
 	close(tmp);
 	return -1;
 }
+
+static int epoll_not_ready_tfd(EventpollTfdEntry *tdefe)
+{
+	struct fdinfo_list_entry *fle;
+
+	list_for_each_entry(fle, &rsti(current)->used, used_list) {
+		if (tdefe->tfd == fle->fe->fd)
+			return (fle->stage < FLE_MAY_BE_POLLED);
+	}
+	BUG();
+	return 0;
+}
+
 static int eventpoll_retore_tfd(int fd, int id, EventpollTfdEntry *tdefe)
 {
 	struct epoll_event event;
@@ -168,11 +182,19 @@ static int eventpoll_post_open(struct file_desc *d, int fd)
 	info = container_of(d, struct eventpoll_file_info, d);
 
 	for (i = 0; i < info->efe->n_tfd; i++) {
+		if (epoll_not_ready_tfd(info->efe->tfd[i]))
+			return ORV_AGAIN;
+	}
+	for (i = 0; i < info->efe->n_tfd; i++) {
 		if (eventpoll_retore_tfd(fd, info->efe->id, info->efe->tfd[i]))
 			return -1;
 	}
 
 	list_for_each_entry(td_info, &eventpoll_tfds, list) {
+		if (epoll_not_ready_tfd(td_info->tdefe))
+			return ORV_AGAIN;
+	}
+	list_for_each_entry(td_info, &eventpoll_tfds, list) {
 		if (td_info->tdefe->id != info->efe->id)
 			continue;
 



More information about the CRIU mailing list