mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-15 15:25:09 -04:00
Prefer epoll_create1 on Linuxen that have it
This commit is contained in:
parent
33fca629a6
commit
bac906c761
@ -310,6 +310,7 @@ AC_CHECK_FUNCS([ \
|
|||||||
arc4random_buf \
|
arc4random_buf \
|
||||||
clock_gettime \
|
clock_gettime \
|
||||||
eventfd \
|
eventfd \
|
||||||
|
epoll_create1 \
|
||||||
fcntl \
|
fcntl \
|
||||||
getegid \
|
getegid \
|
||||||
geteuid \
|
geteuid \
|
||||||
|
23
epoll.c
23
epoll.c
@ -108,19 +108,24 @@ const struct eventop epollops = {
|
|||||||
static void *
|
static void *
|
||||||
epoll_init(struct event_base *base)
|
epoll_init(struct event_base *base)
|
||||||
{
|
{
|
||||||
int epfd;
|
int epfd = -1;
|
||||||
struct epollop *epollop;
|
struct epollop *epollop;
|
||||||
|
|
||||||
/* Initialize the kernel queue. (The size field is ignored since
|
#ifdef _EVENT_HAVE_EPOLL_CREATE1
|
||||||
* 2.6.8.) */
|
/* First, try the shiny new epoll_create1 interface, if we have it. */
|
||||||
if ((epfd = epoll_create(32000)) == -1) {
|
epfd = epoll_create1(EPOLL_CLOEXEC);
|
||||||
if (errno != ENOSYS)
|
#endif
|
||||||
event_warn("epoll_create");
|
if (epfd == -1) {
|
||||||
return (NULL);
|
/* 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)))) {
|
if (!(epollop = mm_calloc(1, sizeof(struct epollop)))) {
|
||||||
close(epfd);
|
close(epfd);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user