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);
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) {
}
}
+ auth_waiting_handshake_count--;
+
if (close(conn->fd) < 0)
i_error("close(auth) failed: %m");
io_remove(conn->io);
conn->available_auth_mechs = handshake->auth_mechanisms;
conn->handshake_received = TRUE;
+ auth_waiting_handshake_count--;
update_available_auth_mechs();
}
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;
{
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);
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)
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)