ioloop-epoll.c revision 49b6e2d72cfaa5c244c798ddbae5b61489b0f728
/* Copyright (c) 2004-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "fd-close-on-exec.h"
#include "ioloop-private.h"
#include "ioloop-iolist.h"
#ifdef IOLOOP_EPOLL
#include <unistd.h>
struct ioloop_handler_context {
int epfd;
unsigned int deleted_count;
};
{
struct ioloop_handler_context *ctx;
i_fatal("epoll_create(): %m");
else {
i_fatal("epoll_create(): %m (you may need to increase "
"/proc/sys/fs/epoll/max_user_instances)");
}
}
}
{
unsigned int i, count;
for (i = 0; i < count; i++)
i_error("close(epoll) failed: %m");
}
{
int events = 0, i;
for (i = 0; i < IOLOOP_IOLIST_IOS_PER_FD; i++) {
continue;
events |= IO_EPOLL_INPUT;
events |= IO_EPOLL_ERROR;
}
return events;
}
{
struct epoll_event event;
int op;
bool first;
i_panic("epoll_ctl(add, %d) failed: %m "
" - instead of '<file', try 'cat file|'");
}
i_panic("epoll_ctl(%s, %d) failed: %m",
}
if (first) {
/* allow epoll_wait() to return the maximum number of events
by keeping space allocated for each file descriptor */
if (ctx->deleted_count > 0)
ctx->deleted_count--;
else
}
}
{
struct epoll_event event;
int op;
bool last;
if (!closed) {
const char *errstr = t_strdup_printf(
"epoll_ctl(%s, %d) failed: %m",
else
}
}
if (last) {
/* since we're not freeing memory in any case, just increase
deleted counter so next handle_add() can just decrease it
insteading of appending to the events array */
ctx->deleted_count++;
}
}
{
struct epoll_event *events;
const struct epoll_event *event;
unsigned int events_count;
bool call;
/* get the time left for next timeout task */
i_fatal("epoll_wait(): %m");
} else {
just wait for them. */
if (msecs < 0)
i_panic("BUG: No IOs or timeouts set. Not waiting for infinity.");
ret = 0;
}
/* execute timeout handlers */
return;
for (i = 0; i < ret; i++) {
/* io_loop_handle_add() may cause events array reallocation,
so we have use array_idx() */
for (j = 0; j < IOLOOP_IOLIST_IOS_PER_FD; j++) {
continue;
if (call)
}
}
}
#endif /* IOLOOP_EPOLL */