ioloop.c revision 1da9355e6497f66ddb50e3c482e00507c7cfd8bc
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenstatic ARRAY(io_switch_callback_t *) io_switch_callbacks = ARRAY_INIT;
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainenstatic bool panic_on_leak = FALSE, panic_on_leak_set = FALSE;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic void io_loop_initialize_handler(struct ioloop *ioloop)
bbce20cb4e5739e9a06058cf8ee1f38a7f6884f6Timo Sirainen initial_fd_count = ioloop->max_fd_count > 0 &&
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ioloop->max_fd_count < IOLOOP_INITIAL_FD_COUNT ?
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ioloop->max_fd_count : IOLOOP_INITIAL_FD_COUNT;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen io_loop_handler_init(ioloop, initial_fd_count);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic struct io_file *
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenio_add_file(int fd, enum io_condition condition,
45e62043058738e294f89504c319d852e25943ccTimo Sirainen /* we're adding an istream whose only way to get notified
45e62043058738e294f89504c319d852e25943ccTimo Sirainen is to call i_stream_set_input_pending() */
6eb30032b4a50c383dea4c9c74342d906de6ad36Timo Sirainenstruct io *io_add(int fd, enum io_condition condition,
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen io = io_add_file(fd, condition, source_filename, source_linenum, callback, context);
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainenstruct io *io_add_istream(struct istream *input, const char *source_filename,
2e99f3f3bb35715ce5e0a75a2f2a9bac3ab4224bTimo Sirainen io = io_add_file(i_stream_get_fd(input), IO_READ, source_filename,
static struct timeout *
return timeout;
unsigned int source_linenum,
if (msecs > 0) {
return timeout;
struct timeout *
unsigned int source_linenum,
struct timeout *
const char *source_filename,
unsigned int source_linenum,
return timeout;
static struct timeout *
return new_to;
int ret;
return ret;
int msecs;
msecs = 0;
return msecs;
unsigned int i, count;
for (i = 0; i < count; i++) {
long long diff =
T_BEGIN {
} T_END;
void io_loop_time_refresh(void)
if (!panic_on_leak_set) {
return ioloop;
if (panic_on_leak)
if (panic_on_leak)
if (panic_on_leak)
if (panic_on_leak)
if (leaks) {
const char *backtrace;
static void io_switch_callbacks_free(void)
unsigned int idx;
i_unreached();
return ctx;
here from activate/deactivate loop */
unsigned int i, count;
for (i = 0; i < count; ) {
return old_io;
return old_to;
return new_to;
return conditions;
struct io_wait_timer *
return timer;
return timer;