Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7104:db5f55daa002 HEAD
Forgot from imap/pop3-login clients hash -> linked list commit.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 04 Jan 2008 02:14:29 +0200 |
parents | 284dd5f2777d |
children | f0ad529ac9ea |
files | src/login-common/client-common.c src/login-common/client-common.h src/login-common/main.c |
diffstat | 3 files changed, 40 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/client-common.c Fri Jan 04 00:36:32 2008 +0200 +++ b/src/login-common/client-common.c Fri Jan 04 02:14:29 2008 +0200 @@ -10,6 +10,37 @@ #include <stdlib.h> +struct client *clients = NULL; +unsigned int clients_count = 0; + +void client_link(struct client *client) +{ + client->prev = NULL; + client->next = clients; + if (clients != NULL) + clients->prev = client; + clients = client; + clients_count++; +} + +void client_unlink(struct client *client) +{ + i_assert(clients_count > 0); + + clients_count--; + if (client->prev == NULL) + clients = client->next; + else + client->prev->next = client->next; + if (client->next != NULL) + client->next->prev = client->prev; +} + +unsigned int clients_get_count(void) +{ + return clients_count; +} + static const struct var_expand_table * get_var_expand_table(struct client *client) {
--- a/src/login-common/client-common.h Fri Jan 04 00:36:32 2008 +0200 +++ b/src/login-common/client-common.h Fri Jan 04 02:14:29 2008 +0200 @@ -6,6 +6,8 @@ #include "sasl-server.h" struct client { + struct client *prev, *next; + struct ip_addr local_ip; struct ip_addr ip; unsigned int local_port, remote_port; @@ -30,17 +32,19 @@ /* ... */ }; +extern struct client *clients; + struct client *client_create(int fd, bool ssl, const struct ip_addr *local_ip, const struct ip_addr *ip); +void client_link(struct client *client); +void client_unlink(struct client *client); +unsigned int clients_get_count(void); + void client_syslog(struct client *client, const char *msg); -unsigned int clients_get_count(void); void clients_notify_auth_connected(void); void client_destroy_oldest(void); void clients_destroy_all(void); -void clients_init(void); -void clients_deinit(void); - #endif
--- a/src/login-common/main.c Fri Jan 04 00:36:32 2008 +0200 +++ b/src/login-common/main.c Fri Jan 04 02:14:29 2008 +0200 @@ -337,7 +337,6 @@ auth_client = auth_client_new(login_process_uid); auth_client_set_connect_notify(auth_client, auth_connect_notify, NULL); - clients_init(); value = getenv("LISTEN_FDS"); listen_count = value == NULL ? 0 : atoi(value); @@ -368,7 +367,7 @@ if (auth_client != NULL) auth_client_free(&auth_client); - clients_deinit(); + clients_destroy_all(); master_deinit(); lib_signals_deinit();