[dovecot-cvs] dovecot/src/auth login-connection.c,1.18,1.19 login-connection.h,1.3,1.4 mech-digest-md5.c,1.6,1.7 mech-plain.c,1.5,1.6 mech.c,1.5,1.6

cras at procontrol.fi cras at procontrol.fi
Sun Feb 2 11:30:21 EET 2003


Update of /home/cvs/dovecot/src/auth
In directory danu:/tmp/cvs-serv14577

Modified Files:
	login-connection.c login-connection.h mech-digest-md5.c 
	mech-plain.c mech.c 
Log Message:
fixes



Index: login-connection.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/login-connection.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- login-connection.c	31 Jan 2003 06:56:58 -0000	1.18
+++ login-connection.c	2 Feb 2003 09:30:18 -0000	1.19
@@ -21,6 +21,8 @@
 static struct auth_login_handshake_output handshake_output;
 static struct login_connection *connections;
 
+static void login_connection_unref(struct login_connection *conn);
+
 static void request_callback(struct auth_login_reply *reply,
 			     const void *data, struct login_connection *conn)
 {
@@ -30,19 +32,23 @@
 	if ((size_t)ret == sizeof(*reply)) {
 		if (reply->data_size == 0) {
 			/* all sent */
+			login_connection_unref(conn);
 			return;
 		}
 
 		ret = o_stream_send(conn->output, data, reply->data_size);
 		if ((size_t)ret == reply->data_size) {
 			/* all sent */
+			login_connection_unref(conn);
 			return;
 		}
 	}
 
 	if (ret >= 0)
 		i_warning("Transmit buffer full for login process, killing it");
+
 	login_connection_destroy(conn);
+	login_connection_unref(conn);
 }
 
 struct login_connection *login_connection_lookup(unsigned int pid)
@@ -112,6 +118,7 @@
 		i_stream_skip(conn->input, sizeof(request));
 
 		/* we have a full init request */
+		conn->refcount++;
 		mech_request_new(conn, &request, request_callback);
 	} else if (type == AUTH_LOGIN_REQUEST_CONTINUE) {
                 struct auth_login_request_continue request;
@@ -126,6 +133,7 @@
 		i_stream_skip(conn->input, sizeof(request) + request.data_size);
 
 		/* we have a full continued request */
+		conn->refcount++;
 		mech_request_continue(conn, &request, data + sizeof(request),
 				      request_callback);
 
@@ -171,6 +179,7 @@
 		i_info("Login process %d connected", fd);
 
 	conn = i_new(struct login_connection, 1);
+	conn->refcount = 1;
 
 	conn->fd = fd;
 	conn->input = i_stream_create_file(fd, default_pool, MAX_INBUF_SIZE,
@@ -207,6 +216,9 @@
 {
 	struct login_connection **pos;
 
+	if (conn->fd == -1)
+		return;
+
 	if (verbose)
 		i_info("Login process %d disconnected", conn->fd);
 
@@ -217,14 +229,27 @@
 		}
 	}
 
+	i_stream_close(conn->input);
+	o_stream_close(conn->output);
+
+	io_remove(conn->io);
+	net_disconnect(conn->fd);
+	conn->fd = -1;
+
+        login_connection_unref(conn);
+}
+
+static void login_connection_unref(struct login_connection *conn)
+{
+	if (--conn->refcount > 0)
+		return;
+
 	hash_foreach(conn->auth_requests, auth_request_hash_destroy, NULL);
 	hash_destroy(conn->auth_requests);
 
 	i_stream_unref(conn->input);
 	o_stream_unref(conn->output);
 
-	io_remove(conn->io);
-	net_disconnect(conn->fd);
 	pool_unref(conn->pool);
 	i_free(conn);
 }

Index: login-connection.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/login-connection.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- login-connection.h	27 Jan 2003 01:33:40 -0000	1.3
+++ login-connection.h	2 Feb 2003 09:30:18 -0000	1.4
@@ -5,6 +5,7 @@
 
 struct login_connection {
 	struct login_connection *next;
+	int refcount;
 
 	int fd;
 	struct io *io;

Index: mech-digest-md5.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech-digest-md5.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mech-digest-md5.c	2 Feb 2003 00:32:21 -0000	1.6
+++ mech-digest-md5.c	2 Feb 2003 09:30:18 -0000	1.7
@@ -567,8 +567,6 @@
 
 	if (parse_digest_response(auth, (const char *) data,
 				  request->data_size, &error)) {
-		auth_request->conn = conn;
-		auth_request->id = request->id;
 		auth_request->callback = callback;
 
 		auth_request->user = p_strdup(auth_request->pool,

Index: mech-plain.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech-plain.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mech-plain.c	2 Feb 2003 00:19:34 -0000	1.5
+++ mech-plain.c	2 Feb 2003 09:30:18 -0000	1.6
@@ -22,8 +22,6 @@
 	char *pass;
 	size_t i, count, len;
 
-	auth_request->conn = conn;
-	auth_request->id = request->id;
 	auth_request->callback = callback;
 
 	/* authorization ID \0 authentication ID \0 pass.

Index: mech.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mech.c	2 Feb 2003 00:19:34 -0000	1.5
+++ mech.c	2 Feb 2003 09:30:18 -0000	1.6
@@ -90,7 +90,10 @@
 	}
 
 	if (auth_request != NULL) {
+		auth_request->conn = conn;
+		auth_request->id = request->id;
 		auth_request->protocol = request->protocol;
+
 		hash_insert(conn->auth_requests, POINTER_CAST(request->id),
 			    auth_request);
 	}
@@ -112,7 +115,7 @@
 	} else {
 		if (!auth_request->auth_continue(conn, auth_request,
 						 request, data, callback))
-                        mech_request_free(conn, auth_request, request->id);
+			mech_request_free(conn, auth_request, request->id);
 	}
 }
 




More information about the dovecot-cvs mailing list