[CRIU] [RFC PATCH 03/12] util: epoll_run: allow interrupting event polling

Mike Rapoport rppt at linux.vnet.ibm.com
Mon Jan 9 00:23:17 PST 2017


If an event handler returns a positive value, the event polling and
handling loop is interrupted after all the pending events indicated by
epoll_wait are processed.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/util.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/criu/util.c b/criu/util.c
index 4349b34..fa1d749 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -1214,6 +1214,7 @@ int epoll_add_rfd(int epfd, struct epoll_rfd *rfd)
 int epoll_run_rfds(int epollfd, struct epoll_event *evs, int nr_fds, int timeout)
 {
 	int ret, i, nr_events;
+	bool have_a_break = false;
 
 	while (1) {
 		/* FIXME -- timeout should decrease over time...  */
@@ -1234,7 +1235,12 @@ int epoll_run_rfds(int epollfd, struct epoll_event *evs, int nr_fds, int timeout
 			ret = rfd->revent(rfd);
 			if (ret < 0)
 				goto out;
+			if (ret > 0)
+				have_a_break = true;
 		}
+
+		if (have_a_break)
+			return 1;
 	}
 out:
 	return ret;
-- 
1.9.1



More information about the CRIU mailing list