Skip to content

Commit

Permalink
Prefer epoll_create1 on Linuxen that have it
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Feb 10, 2012
1 parent 33fca62 commit bac906c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ AC_CHECK_FUNCS([ \
arc4random_buf \
clock_gettime \
eventfd \
epoll_create1 \
fcntl \
getegid \
geteuid \
Expand Down
23 changes: 14 additions & 9 deletions epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,24 @@ const struct eventop epollops = {
static void *
epoll_init(struct event_base *base)
{
int epfd;
int epfd = -1;
struct epollop *epollop;

/* Initialize the kernel queue. (The size field is ignored since
* 2.6.8.) */
if ((epfd = epoll_create(32000)) == -1) {
if (errno != ENOSYS)
event_warn("epoll_create");
return (NULL);
#ifdef _EVENT_HAVE_EPOLL_CREATE1
/* First, try the shiny new epoll_create1 interface, if we have it. */
epfd = epoll_create1(EPOLL_CLOEXEC);
#endif
if (epfd == -1) {
/* Initialize the kernel queue using the old interface. (The
size field is ignored since 2.6.8.) */
if ((epfd = epoll_create(32000)) == -1) {
if (errno != ENOSYS)
event_warn("epoll_create");
return (NULL);
}
evutil_make_socket_closeonexec(epfd);
}

evutil_make_socket_closeonexec(epfd);

if (!(epollop = mm_calloc(1, sizeof(struct epollop)))) {
close(epfd);
return (NULL);
Expand Down

0 comments on commit bac906c

Please sign in to comment.