[dovecot-cvs] dovecot: Check idle timeouts only when there are clients connected.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jun 3 18:00:01 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/0021765627f3
changeset: 5671:0021765627f3
user: Timo Sirainen <tss at iki.fi>
date: Sun Jun 03 17:59:55 2007 +0300
description:
Check idle timeouts only when there are clients connected.
diffstat:
2 files changed, 17 insertions(+), 6 deletions(-)
src/imap-login/client.c | 11 ++++++++---
src/pop3-login/client.c | 12 +++++++++---
diffs (93 lines):
diff -r 2e1fed4f0138 -r 0021765627f3 src/imap-login/client.c
--- a/src/imap-login/client.c Wed May 30 17:04:50 2007 +0300
+++ b/src/imap-login/client.c Sun Jun 03 17:59:55 2007 +0300
@@ -49,6 +49,8 @@ static struct hash_table *clients;
static struct hash_table *clients;
static struct timeout *to_idle;
+static void idle_timeout(void *context);
+
static void client_set_title(struct imap_client *client)
{
const char *addr;
@@ -446,6 +448,8 @@ struct client *client_create(int fd, boo
client_send_greeting(client);
client_set_title(client);
+ if (to_idle == NULL)
+ to_idle = timeout_add(1000, idle_timeout, NULL);
return &client->common;
}
@@ -459,6 +463,8 @@ void client_destroy(struct imap_client *
client_syslog(&client->common, reason);
hash_remove(clients, client);
+ if (hash_size(clients) == 0)
+ timeout_remove(&to_idle);
if (client->input != NULL)
i_stream_close(client->input);
@@ -630,7 +636,6 @@ void clients_init(void)
void clients_init(void)
{
clients = hash_create(system_pool, system_pool, 128, NULL, NULL);
- to_idle = timeout_add(1000, idle_timeout, NULL);
}
void clients_deinit(void)
@@ -638,5 +643,5 @@ void clients_deinit(void)
clients_destroy_all();
hash_destroy(clients);
- timeout_remove(&to_idle);
-}
+ i_assert(to_idle == NULL);
+}
diff -r 2e1fed4f0138 -r 0021765627f3 src/pop3-login/client.c
--- a/src/pop3-login/client.c Wed May 30 17:04:50 2007 +0300
+++ b/src/pop3-login/client.c Sun Jun 03 17:59:55 2007 +0300
@@ -46,6 +46,8 @@ static struct hash_table *clients;
static struct hash_table *clients;
static struct timeout *to_idle;
+static void idle_timeout(void *context);
+
static void client_set_title(struct pop3_client *client)
{
const char *addr;
@@ -337,6 +339,9 @@ struct client *client_create(int fd, boo
if (client->auth_connected)
client_auth_ready(client);
client_set_title(client);
+
+ if (to_idle == NULL)
+ to_idle = timeout_add(1000, idle_timeout, NULL);
return &client->common;
}
@@ -350,6 +355,8 @@ void client_destroy(struct pop3_client *
client_syslog(&client->common, reason);
hash_remove(clients, client);
+ if (hash_size(clients) == 0)
+ timeout_remove(&to_idle);
if (client->input != NULL)
i_stream_close(client->input);
@@ -512,7 +519,6 @@ void clients_init(void)
void clients_init(void)
{
clients = hash_create(system_pool, system_pool, 128, NULL, NULL);
- to_idle = timeout_add(1000, idle_timeout, NULL);
}
void clients_deinit(void)
@@ -520,5 +526,5 @@ void clients_deinit(void)
clients_destroy_all();
hash_destroy(clients);
- timeout_remove(&to_idle);
-}
+ i_assert(to_idle == NULL);
+}
More information about the dovecot-cvs
mailing list