Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5671:0021765627f3 HEAD
Check idle timeouts only when there are clients connected.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 03 Jun 2007 17:59:55 +0300 |
parents | 2e1fed4f0138 |
children | ca38eb4189e8 |
files | src/imap-login/client.c src/pop3-login/client.c |
diffstat | 2 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 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 @@ 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 @@ 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) { 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 @@ clients_destroy_all(); hash_destroy(clients); - timeout_remove(&to_idle); + i_assert(to_idle == NULL); }
--- 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 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 @@ 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 @@ 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) { 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 @@ clients_destroy_all(); hash_destroy(clients); - timeout_remove(&to_idle); + i_assert(to_idle == NULL); }