Mercurial > dovecot > core-2.2
changeset 17940:c4e587d1e8ac
auth: Make sure userdb iteration is destroyed if worker connection disconnects.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 11 Oct 2014 00:02:00 +0300 |
parents | a36fe1250606 |
children | 871a5b807ad0 |
files | src/auth/auth-master-connection.c src/auth/auth-master-connection.h |
diffstat | 2 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/auth-master-connection.c Sat Oct 11 00:01:09 2014 +0300 +++ b/src/auth/auth-master-connection.c Sat Oct 11 00:02:00 2014 +0300 @@ -435,6 +435,9 @@ static void master_input_list_finish(struct master_list_iter_ctx *ctx) { + i_assert(ctx->conn->iter_ctx == ctx); + + ctx->conn->iter_ctx = NULL; ctx->conn->io = io_add(ctx->conn->fd, IO_READ, master_input, ctx->conn); if (ctx->iter != NULL) @@ -532,6 +535,13 @@ } list++; + if (conn->iter_ctx != NULL) { + i_error("Auth client is already iterating users"); + str = t_strdup_printf("DONE\t%u\tfail\n", id); + o_stream_nsend_str(conn->output, str); + return TRUE; + } + if (conn->userdb_restricted_uid != 0) { i_error("Auth client doesn't have permissions to list users: %s", auth_restricted_reason(conn)); @@ -587,6 +597,7 @@ o_stream_set_flush_callback(conn->output, master_output_list, ctx); ctx->iter = userdb_blocking_iter_init(auth_request, master_input_list_callback, ctx); + conn->iter_ctx = ctx; return TRUE; } @@ -766,6 +777,8 @@ DLLIST_REMOVE(&auth_master_connections, conn); + if (conn->iter_ctx != NULL) + master_input_list_finish(conn->iter_ctx); if (conn->input != NULL) i_stream_close(conn->input); if (conn->output != NULL)
--- a/src/auth/auth-master-connection.h Sat Oct 11 00:01:09 2014 +0300 +++ b/src/auth/auth-master-connection.h Sat Oct 11 00:02:00 2014 +0300 @@ -15,7 +15,7 @@ struct ostream *output; struct io *io; - struct auth_request_list *requests; + struct master_list_iter_ctx *iter_ctx; /* If non-zero, allow only USER lookups whose returned uid matches this uid. Don't allow LIST/PASS lookups. */ uid_t userdb_restricted_uid;