dovecot-2.0: auth master: Fixed hanging when iterating through u...

dovecot at dovecot.org dovecot at dovecot.org
Fri May 15 23:06:18 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/3d628e998192
changeset: 9293:3d628e998192
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 15 16:05:25 2009 -0400
description:
auth master: Fixed hanging when iterating through users.

diffstat:

1 file changed, 36 insertions(+), 26 deletions(-)
src/lib-auth/auth-master.c |   62 +++++++++++++++++++++++++-------------------

diffs (83 lines):

diff -r de33ce3795da -r 3d628e998192 src/lib-auth/auth-master.c
--- a/src/lib-auth/auth-master.c	Fri May 15 15:35:06 2009 -0400
+++ b/src/lib-auth/auth-master.c	Fri May 15 16:05:25 2009 -0400
@@ -185,9 +185,39 @@ static bool auth_user_reply_callback(con
 	return FALSE;
 }
 
+static bool
+auth_handle_line(struct auth_master_connection *conn, const char *line)
+{
+	const char *cmd, *const *args, *id, *wanted_id;
+
+	args = t_strsplit(line, "\t");
+	cmd = *args; args++;
+	if (*args == NULL)
+		id = "";
+	else {
+		id = *args;
+		args++;
+	}
+
+	wanted_id = dec2str(conn->request_counter);
+	if (strcmp(id, wanted_id) == 0)
+		return conn->reply_callback(cmd, args, conn->reply_context);
+
+	if (strcmp(cmd, "CUID") == 0) {
+		i_error("%s: %s is an auth client socket. "
+			"It should be a master socket.",
+			conn->prefix, conn->auth_socket_path);
+	} else {
+		i_error("%s: BUG: Unexpected input: %s", conn->prefix, line);
+	}
+	auth_request_lookup_abort(conn);
+	return FALSE;
+}
+
 static void auth_input(struct auth_master_connection *conn)
 {
-	const char *line, *cmd, *const *args, *id, *wanted_id;
+	const char *line;
+	bool ret;
 
 	switch (i_stream_read(conn->input)) {
 	case 0:
@@ -211,33 +241,13 @@ static void auth_input(struct auth_maste
 			return;
 	}
 
-	line = i_stream_next_line(conn->input);
-	if (line == NULL)
-		return;
-
-	args = t_strsplit(line, "\t");
-	cmd = *args; args++;
-	if (*args == NULL)
-		id = "";
-	else {
-		id = *args;
-		args++;
-	}
-
-	wanted_id = dec2str(conn->request_counter);
-	if (strcmp(id, wanted_id) == 0) {
-		if (conn->reply_callback(cmd, args, conn->reply_context))
+	while ((line = i_stream_next_line(conn->input)) != NULL) {
+		T_BEGIN {
+			ret = auth_handle_line(conn, line);
+		} T_END;
+		if (!ret)
 			return;
 	}
-	
-	if (strcmp(cmd, "CUID") == 0) {
-		i_error("%s: %s is an auth client socket. "
-			"It should be a master socket.",
-			conn->prefix, conn->auth_socket_path);
-	} else {
-		i_error("%s: BUG: Unexpected input: %s", conn->prefix, line);
-	}
-	auth_request_lookup_abort(conn);
 }
 
 static int auth_master_connect(struct auth_master_connection *conn)


More information about the dovecot-cvs mailing list