Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 53b1578

Browse files
committed
Cope with glibc too old to have epoll_create1().
Commit fa31b6f supposed that we didn't have to worry about that anymore, but it seems that RHEL5 is like that, and that's still a supported platform. Put back the prior coding under an #ifdef, adding an explicit fcntl() to retain the desired CLOEXEC property. Discussion: https://postgr.es/m/12307.1493325329@sss.pgh.pa.us
1 parent 28afff3 commit 53b1578

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/backend/storage/ipc/latch.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,18 @@ CreateWaitEventSet(MemoryContext context, int nevents)
574574
set->nevents_space = nevents;
575575

576576
#if defined(WAIT_USE_EPOLL)
577+
#ifdef EPOLL_CLOEXEC
577578
set->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
578579
if (set->epoll_fd < 0)
579580
elog(ERROR, "epoll_create1 failed: %m");
581+
#else
582+
/* cope with ancient glibc lacking epoll_create1 (e.g., RHEL5) */
583+
set->epoll_fd = epoll_create(nevents);
584+
if (set->epoll_fd < 0)
585+
elog(ERROR, "epoll_create failed: %m");
586+
if (fcntl(set->epoll_fd, F_SETFD, FD_CLOEXEC) == -1)
587+
elog(ERROR, "fcntl(F_SETFD) failed on epoll descriptor: %m");
588+
#endif /* EPOLL_CLOEXEC */
580589
#elif defined(WAIT_USE_WIN32)
581590

582591
/*

0 commit comments

Comments
 (0)