Hello, Commit 82ebbeb0 added a workaround for (already in 2017) ancient Linux kernels with no EPOLL_CLOEXEC. I don't see any such systems in the build farm today (and if there is one hiding in there somewhere, it's well past time to upgrade). I'd like to rip that code out, because I'm about to commit some new code that uses another 2.6.17+ XXX_CLOEXEC flag, and it'd be silly to have to write new workaround code for that too, and a contradiction to have fallback code in one place but not another. Any objections?
From 9c6ac992f60a904f8073e62b1b8085ff9df7ae0b Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Sat, 27 Feb 2021 11:22:16 +1300 Subject: [PATCH] Remove latch.c workaround for Linux < 2.6.27.
Ancient Linux had no EPOLL_CLOEXEC flag, so commit 82ebbeb0 added a separate code path with an fcntl() call. Kernels of that vintage are long gone. Now seems like a good time to drop this extra code, because otherwise we'd have to add similar workaround code to new patches using XXX_CLOEXEC flags to avoid contradicting ourselves. --- src/backend/storage/ipc/latch.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c index f2d005eea0..79b9627831 100644 --- a/src/backend/storage/ipc/latch.c +++ b/src/backend/storage/ipc/latch.c @@ -666,31 +666,12 @@ CreateWaitEventSet(MemoryContext context, int nevents) /* treat this as though epoll_create1 itself returned EMFILE */ elog(ERROR, "epoll_create1 failed: %m"); } -#ifdef EPOLL_CLOEXEC set->epoll_fd = epoll_create1(EPOLL_CLOEXEC); if (set->epoll_fd < 0) { ReleaseExternalFD(); elog(ERROR, "epoll_create1 failed: %m"); } -#else - /* cope with ancient glibc lacking epoll_create1 (e.g., RHEL5) */ - set->epoll_fd = epoll_create(nevents); - if (set->epoll_fd < 0) - { - ReleaseExternalFD(); - elog(ERROR, "epoll_create failed: %m"); - } - if (fcntl(set->epoll_fd, F_SETFD, FD_CLOEXEC) == -1) - { - int save_errno = errno; - - close(set->epoll_fd); - ReleaseExternalFD(); - errno = save_errno; - elog(ERROR, "fcntl(F_SETFD) failed on epoll descriptor: %m"); - } -#endif /* EPOLL_CLOEXEC */ #elif defined(WAIT_USE_KQUEUE) if (!AcquireExternalFD()) { @@ -736,7 +717,7 @@ CreateWaitEventSet(MemoryContext context, int nevents) * * Note: preferably, this shouldn't have to free any resources that could be * inherited across an exec(). If it did, we'd likely leak those resources in - * many scenarios. For the epoll case, we ensure that by setting FD_CLOEXEC + * many scenarios. For the epoll case, we ensure that by setting EPOLL_CLOEXEC * when the FD is created. For the Windows case, we assume that the handles * involved are non-inheritable. */ -- 2.30.0