ioloop-epoll.c revision 9097014815990de521654305dec6a8d5d29407f2
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* Copyright (c) 2004-2014 Dovecot authors, see the included COPYING file */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned int deleted_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid io_loop_handler_init(struct ioloop *ioloop, unsigned int initial_fd_count)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ioloop->handler_context = ctx = i_new(struct ioloop_handler_context, 1);
b1352070d318187b41b088da3533692976f3f225Alan Wrightvoid io_loop_handler_deinit(struct ioloop *ioloop)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct ioloop_handler_context *ctx = ioloop->handler_context;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned int i, count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (i = 0; i < count; i++)
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States i_free(list[i]);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (close(ctx->epfd) < 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb#define IO_EPOLL_INPUT (EPOLLIN | EPOLLPRI | IO_EPOLL_ERROR)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb int events = 0, i;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb for (i = 0; i < IOLOOP_IOLIST_IOS_PER_FD; i++) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct ioloop_handler_context *ctx = io->io.ioloop->handler_context;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States io->fd != STDIN_FILENO ? "" :
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw " - instead of '<file', try 'cat file|'");
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* allow epoll_wait() to return the maximum number of events
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as by keeping space allocated for each file descriptor */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Rossvoid io_loop_handle_remove(struct io_file *io, bool closed)
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as struct ioloop_handler_context *ctx = io->io.ioloop->handler_context;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw "epoll_ctl(%s, %d) failed: %m",
7b59d02d2a384be9a08087b14defadd214b3c1ddjb /* since we're not freeing memory in any case, just increase
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb deleted counter so next handle_add() can just decrease it
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb insteading of appending to the events array */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb struct ioloop_handler_context *ctx = ioloop->handler_context;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned int events_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* get the time left for next timeout task */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb events = array_get_modifiable(&ctx->events, &events_count);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ret = epoll_wait(ctx->epfd, events, events_count, msecs);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* no I/Os, but we should have some timeouts.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb just wait for them. */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* execute timeout handlers */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb for (i = 0; i < ret; i++) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* io_loop_handle_add() may cause events array reallocation,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw so we have use array_idx() */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross for (j = 0; j < IOLOOP_IOLIST_IOS_PER_FD; j++) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if ((event->events & (EPOLLHUP | EPOLLERR)) != 0)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross#endif /* IOLOOP_EPOLL */