dovecot-2.2: Use timeout_add_short() for sub-second timeouts. Fa...
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 20 03:33:26 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/a47c95872745
changeset: 14577:a47c95872745
user: Timo Sirainen <tss at iki.fi>
date: Sun May 20 03:32:55 2012 +0300
description:
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.
diffstat:
src/auth/auth-request-handler.c | 4 ++--
src/director/director-test.c | 4 ++--
src/lib-storage/index/imapc/imapc-mailbox.c | 4 ++--
src/lib-storage/index/index-mailbox-check.c | 4 ++--
src/lib/ioloop.c | 8 ++++++++
src/lib/ioloop.h | 7 +++++++
src/plugins/fts/fts-indexer.c | 2 +-
src/plugins/replication/replication-plugin.c | 4 ++--
8 files changed, 26 insertions(+), 11 deletions(-)
diffs (117 lines):
diff -r fbb1ecb9b888 -r a47c95872745 src/auth/auth-request-handler.c
--- 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);
}
}
diff -r fbb1ecb9b888 -r a47c95872745 src/director/director-test.c
--- 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);
diff -r fbb1ecb9b888 -r a47c95872745 src/lib-storage/index/imapc/imapc-mailbox.c
--- 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);
}
}
diff -r fbb1ecb9b888 -r a47c95872745 src/lib-storage/index/index-mailbox-check.c
--- 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);
}
}
diff -r fbb1ecb9b888 -r a47c95872745 src/lib/ioloop.c
--- 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)
diff -r fbb1ecb9b888 -r a47c95872745 src/lib/ioloop.h
--- 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);
diff -r fbb1ecb9b888 -r a47c95872745 src/plugins/fts/fts-indexer.c
--- 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);
diff -r fbb1ecb9b888 -r a47c95872745 src/plugins/replication/replication-plugin.c
--- 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);
}
}
More information about the dovecot-cvs
mailing list