Mercurial > dovecot > core-2.2
changeset 14577:a47c95872745
Use timeout_add_short() for sub-second timeouts. Fail at compile time if timeout_add() is <1s.
In future timeout_add() could perhaps also be made less precise, so that it
would try to group timeouts to run around at the same time.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 20 May 2012 03:32:55 +0300 |
parents | fbb1ecb9b888 |
children | ad6aa4e042f5 |
files | src/auth/auth-request-handler.c src/director/director-test.c src/lib-storage/index/imapc/imapc-mailbox.c src/lib-storage/index/index-mailbox-check.c src/lib/ioloop.c src/lib/ioloop.h src/plugins/fts/fts-indexer.c src/plugins/replication/replication-plugin.c |
diffstat | 8 files changed, 26 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/auth-request-handler.c Sun May 20 03:25:04 2012 +0300 +++ b/src/auth/auth-request-handler.c Sun May 20 03:32:55 2012 +0300 @@ -231,8 +231,8 @@ aqueue_append(auth_failures, &request); if (to_auth_failures == NULL) { to_auth_failures = - timeout_add(AUTH_FAILURE_DELAY_CHECK_MSECS, - auth_failure_timeout, NULL); + timeout_add_short(AUTH_FAILURE_DELAY_CHECK_MSECS, + auth_failure_timeout, NULL); } }
--- a/src/director/director-test.c Sun May 20 03:25:04 2012 +0300 +++ b/src/director/director-test.c Sun May 20 03:32:55 2012 +0300 @@ -450,8 +450,8 @@ if (conn->fd == -1) i_fatal("net_connect_unix(%s) failed: %m", path); conn->io = io_add(conn->fd, IO_READ, admin_input, conn); - conn->to_random = timeout_add(ADMIN_RANDOM_TIMEOUT_MSECS, - admin_random_action, conn); + conn->to_random = timeout_add_short(ADMIN_RANDOM_TIMEOUT_MSECS, + admin_random_action, conn); net_set_nonblock(conn->fd, FALSE); conn->input = i_stream_create_fd(conn->fd, (size_t)-1, TRUE);
--- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun May 20 03:25:04 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun May 20 03:32:55 2012 +0300 @@ -117,8 +117,8 @@ mbox->to_idle_delay == NULL) { io_loop_set_current(mbox->storage->root_ioloop); mbox->to_idle_delay = - timeout_add(NOTIFY_DELAY_MSECS, - imapc_mailbox_idle_timeout, mbox); + timeout_add_short(NOTIFY_DELAY_MSECS, + imapc_mailbox_idle_timeout, mbox); io_loop_set_current(old_ioloop); } }
--- a/src/lib-storage/index/index-mailbox-check.c Sun May 20 03:25:04 2012 +0300 +++ b/src/lib-storage/index/index-mailbox-check.c Sun May 20 03:32:55 2012 +0300 @@ -59,8 +59,8 @@ if (ibox->notify_delay_to == NULL) { ibox->notify_delay_to = - timeout_add(NOTIFY_DELAY_MSECS, - notify_delay_callback, box); + timeout_add_short(NOTIFY_DELAY_MSECS, + notify_delay_callback, box); } }
--- a/src/lib/ioloop.c Sun May 20 03:25:04 2012 +0300 +++ b/src/lib/ioloop.c Sun May 20 03:32:55 2012 +0300 @@ -165,6 +165,14 @@ return timeout; } +#undef timeout_add_short +struct timeout * +timeout_add_short(unsigned int msecs, unsigned int source_linenum, + timeout_callback_t *callback, void *context) +{ + return timeout_add(msecs, source_linenum, callback, context); +} + static void timeout_free(struct timeout *timeout) { if (timeout->ctx != NULL)
--- a/src/lib/ioloop.h Sun May 20 03:25:04 2012 +0300 +++ b/src/lib/ioloop.h Sun May 20 03:32:55 2012 +0300 @@ -73,6 +73,13 @@ timeout_callback_t *callback, void *context); #define timeout_add(msecs, callback, context) \ CONTEXT_CALLBACK(timeout_add, timeout_callback_t, \ + callback, context, msecs, __LINE__), \ + (void)COMPILE_ERROR_IF_TRUE(__builtin_constant_p(msecs) && (msecs > 0 && msecs < 1000)) +struct timeout * +timeout_add_short(unsigned int msecs, unsigned int source_linenum, + timeout_callback_t *callback, void *context); +#define timeout_add_short(msecs, callback, context) \ + CONTEXT_CALLBACK(timeout_add_short, timeout_callback_t, \ callback, context, msecs, __LINE__) /* Remove timeout handler, and set timeout pointer to NULL. */ void timeout_remove(struct timeout **timeout);
--- a/src/plugins/fts/fts-indexer.c Sun May 20 03:25:04 2012 +0300 +++ b/src/plugins/fts/fts-indexer.c Sun May 20 03:32:55 2012 +0300 @@ -212,7 +212,7 @@ asynchronous waits, get rid of this wait and use the mail IO loop */ ioloop = io_loop_create(); io = io_add(ctx->fd, IO_READ, io_loop_stop, ioloop); - to = timeout_add(INDEXER_WAIT_MSECS, io_loop_stop, ioloop); + to = timeout_add_short(INDEXER_WAIT_MSECS, io_loop_stop, ioloop); io_loop_run(ioloop); io_remove(&io); timeout_remove(&to);
--- a/src/plugins/replication/replication-plugin.c Sun May 20 03:25:04 2012 +0300 +++ b/src/plugins/replication/replication-plugin.c Sun May 20 03:32:55 2012 +0300 @@ -206,8 +206,8 @@ if (ruser->priority < priority) ruser->priority = priority; if (ruser->to == NULL) { - ruser->to = timeout_add(REPLICATION_NOTIFY_DELAY_MSECS, - replication_notify_now, ns->owner); + ruser->to = timeout_add_short(REPLICATION_NOTIFY_DELAY_MSECS, + replication_notify_now, ns->owner); } }