From 0a8b4d1a8b451aca744945235959ec64d7a09d7e Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Mon, 17 Dec 2018 09:35:12 -0800 Subject: [PATCH] use epoll_create1 epoll_create leaks file descriptors. Use epoll_create1(EPOLL_CLOEXEC) instead. Bug: 120983106 Test: compiles and boots Change-Id: I7c135ee22aee61cc7895486fda904b1790c093d1 --- libutils/Looper.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libutils/Looper.cpp b/libutils/Looper.cpp index 102fdf037..b3f943d42 100644 --- a/libutils/Looper.cpp +++ b/libutils/Looper.cpp @@ -51,9 +51,6 @@ int SimpleLooperCallback::handleEvent(int fd, int events, void* data) { // --- Looper --- -// Hint for number of file descriptors to be associated with the epoll instance. -static const int EPOLL_SIZE_HINT = 8; - // Maximum number of file descriptors for which to retrieve poll events each iteration. static const int EPOLL_MAX_EVENTS = 16; @@ -139,7 +136,7 @@ void Looper::rebuildEpollLocked() { } // Allocate the new epoll instance and register the wake pipe. - mEpollFd.reset(epoll_create(EPOLL_SIZE_HINT)); + mEpollFd.reset(epoll_create1(EPOLL_CLOEXEC)); LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance: %s", strerror(errno)); struct epoll_event eventItem;