[dovecot-cvs] dovecot/src/login-common auth-connection.c,1.8,1.9 auth-connection.h,1.3,1.4 main.c,1.3,1.4

cras at procontrol.fi cras at procontrol.fi
Mon Feb 10 09:56:25 EET 2003


Update of /home/cvs/dovecot/src/login-common
In directory danu:/tmp/cvs-serv29691

Modified Files:
	auth-connection.c auth-connection.h main.c 
Log Message:
Don't accept client connections before we're connected to all auth processes.



Index: auth-connection.c
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/auth-connection.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- auth-connection.c	10 Feb 2003 07:37:23 -0000	1.8
+++ auth-connection.c	10 Feb 2003 07:56:23 -0000	1.9
@@ -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);

Index: auth-connection.h
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/auth-connection.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- auth-connection.h	2 Feb 2003 10:53:43 -0000	1.3
+++ auth-connection.h	10 Feb 2003 07:56:23 -0000	1.4
@@ -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);
 

Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- main.c	8 Feb 2003 15:42:46 -0000	1.3
+++ main.c	10 Feb 2003 07:56:23 -0000	1.4
@@ -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)
@@ -94,6 +101,13 @@
 	struct client *client;
 	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) {




More information about the dovecot-cvs mailing list