[5/5] uffd: Relax counting the number of sockets

Submitted by Pavel Emelianov on Nov. 22, 2016, 12:11 p.m.

Details

Message ID 583435F1.3070508@virtuozzo.com
State Accepted
Series "Some more cleanups over uffd.c"
Commit d3ac50770cfabafe58756e9908f662cee6230f08
Headers show

Commit Message

Pavel Emelianov Nov. 22, 2016, 12:11 p.m.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---
 criu/uffd.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/uffd.c b/criu/uffd.c
index 97e2b17..8e64d96 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -108,13 +108,6 @@  static void lpi_fini(struct lazy_pages_info *lpi)
 	free(lpi);
 }
 
-static int epoll_nr_fds(int nr_tasks)
-{
-       if (opts.use_page_server)
-               return nr_tasks + 1;
-       return nr_tasks;
-}
-
 static int prepare_sock_addr(struct sockaddr_un *saddr)
 {
 	int len;
@@ -730,12 +723,12 @@  static int lazy_pages_summary(struct lazy_pages_info *lpi)
 
 #define POLL_TIMEOUT 5000
 
-static int handle_requests(int epollfd, struct epoll_event *events)
+static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
 {
 	struct lazy_pages_info *lpi;
 	int ret;
 
-	ret = epoll_run_rfds(epollfd, events, epoll_nr_fds(task_entries->nr_tasks), POLL_TIMEOUT);
+	ret = epoll_run_rfds(epollfd, events, nr_fds, POLL_TIMEOUT);
 	if (ret < 0)
 		goto out;
 
@@ -849,7 +842,7 @@  int cr_lazy_pages(bool daemon)
 		}
 	}
 
-	nr_fds = epoll_nr_fds(task_entries->nr_tasks);
+	nr_fds = task_entries->nr_tasks + (opts.use_page_server ? 1 : 0);
 	epollfd = epoll_prepare(nr_fds, &events);
 	if (epollfd < 0)
 		return -1;
@@ -862,7 +855,7 @@  int cr_lazy_pages(bool daemon)
 			return -1;
 	}
 
-	ret = handle_requests(epollfd, events);
+	ret = handle_requests(epollfd, events, nr_fds);
 
 	return ret;
 }