Mercurial > dovecot > core-2.2
changeset 1134:bd3dabaa598e HEAD
Don't accept client connections before we're connected to all auth processes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 10 Feb 2003 09:56:23 +0200 |
parents | f6889bb50a7f |
children | 81930fff13cf |
files | src/login-common/auth-connection.c src/login-common/auth-connection.h src/login-common/main.c |
diffstat | 3 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/auth-connection.c Mon Feb 10 09:38:01 2003 +0200 +++ b/src/login-common/auth-connection.c Mon Feb 10 09:56:23 2003 +0200 @@ -25,6 +25,7 @@ static unsigned int request_id_counter; static struct auth_connection *auth_connections; static struct timeout *to; +static unsigned int auth_waiting_handshake_count; static void auth_connection_destroy(struct auth_connection *conn); static void auth_connection_unref(struct auth_connection *conn); @@ -76,6 +77,7 @@ auth_connections = conn; /* send our handshake */ + auth_waiting_handshake_count++; memset(&handshake, 0, sizeof(handshake)); handshake.pid = login_process_uid; if (o_stream_send(conn->output, &handshake, sizeof(handshake)) < 0) { @@ -117,6 +119,8 @@ } } + auth_waiting_handshake_count--; + if (close(conn->fd) < 0) i_error("close(auth) failed: %m"); io_remove(conn->io); @@ -195,6 +199,7 @@ conn->available_auth_mechs = handshake->auth_mechanisms; conn->handshake_received = TRUE; + auth_waiting_handshake_count--; update_available_auth_mechs(); } @@ -359,6 +364,11 @@ auth_connection_unref(request->conn); } +int auth_is_connected(void) +{ + return !auth_reconnect && auth_waiting_handshake_count == 0; +} + static void auth_connect_missing(void) { DIR *dirp; @@ -404,7 +414,8 @@ { auth_connections = NULL; request_id_counter = 0; - auth_reconnect = FALSE; + auth_reconnect = FALSE; + auth_waiting_handshake_count = 0; auth_connect_missing(); to = timeout_add(1000, auth_connect_missing_timeout, NULL);
--- a/src/login-common/auth-connection.h Mon Feb 10 09:38:01 2003 +0200 +++ b/src/login-common/auth-connection.h Mon Feb 10 09:56:23 2003 +0200 @@ -55,6 +55,8 @@ void auth_request_ref(struct auth_request *request); void auth_request_unref(struct auth_request *request); +int auth_is_connected(void); + void auth_connection_init(void); void auth_connection_deinit(void);
--- a/src/login-common/main.c Mon Feb 10 09:38:01 2003 +0200 +++ b/src/login-common/main.c Mon Feb 10 09:56:23 2003 +0200 @@ -76,6 +76,13 @@ struct ip_addr ip; int fd; + if (!auth_is_connected()) { + /* we're not yet connected to auth process - + don't accept client connections. FIXME: eats CPU if + none of the other login processes accept it either.. */ + return; + } + fd = net_accept(LOGIN_LISTEN_FD, &ip, NULL); if (fd < 0) { if (fd < -1) @@ -95,6 +102,13 @@ struct ip_addr ip; int fd, fd_ssl; + if (!auth_is_connected()) { + /* we're not yet connected to auth process - + don't accept client connections. FIXME: eats CPU if + none of the other login processes accept it either.. */ + return; + } + fd = net_accept(LOGIN_SSL_LISTEN_FD, &ip, NULL); if (fd < 0) { if (fd < -1)