[CRIU] [RFC PATCH 02/12] util: epoll_run: fix event processing loop

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


The number of pending events returned by epoll_wait is overridden by the
first call to an event handler. Using an additional local variable resolves
this issue.

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

diff --git a/criu/util.c b/criu/util.c
index 2534a70..4349b34 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -1213,7 +1213,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 = 0, i;
+	int ret, i, nr_events;
 
 	while (1) {
 		/* FIXME -- timeout should decrease over time...  */
@@ -1226,7 +1226,8 @@ int epoll_run_rfds(int epollfd, struct epoll_event *evs, int nr_fds, int timeout
 			break;
 		}
 
-		for (i = 0; i < ret; i++) {
+		nr_events = ret;
+		for (i = 0; i < nr_events; i++) {
 			struct epoll_rfd *rfd;
 
 			rfd = (struct epoll_rfd *)evs[i].data.ptr;
-- 
1.9.1



More information about the CRIU mailing list