Mercurial > dovecot > core-2.2
changeset 12212:bc782780d0fe
auth: Don't assert-crash if a request still succeeds after its client connection is gone.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 30 Sep 2010 17:49:17 +0100 |
parents | dfa2b49d8298 |
children | d6582f3ee54d |
files | src/auth/auth-client-connection.c src/auth/auth-request-handler.c src/auth/auth-request-handler.h |
diffstat | 3 files changed, 26 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/auth-client-connection.c Thu Sep 30 17:12:55 2010 +0100 +++ b/src/auth/auth-client-connection.c Thu Sep 30 17:49:17 2010 +0100 @@ -352,7 +352,7 @@ if (conn->request_handler != NULL) { if (abort_requests) auth_request_handler_abort_requests(conn->request_handler); - auth_request_handler_unref(&conn->request_handler); + auth_request_handler_destroy(&conn->request_handler); } master_service_client_connection_destroyed(master_service);
--- a/src/auth/auth-request-handler.c Thu Sep 30 17:12:55 2010 +0100 +++ b/src/auth/auth-request-handler.c Thu Sep 30 17:49:17 2010 +0100 @@ -29,6 +29,8 @@ void *context; auth_request_callback_t *master_callback; + + unsigned int destroyed:1; }; static ARRAY_DEFINE(auth_failures_arr, struct auth_request *); @@ -103,6 +105,18 @@ pool_unref(&handler->pool); } +void auth_request_handler_destroy(struct auth_request_handler **_handler) +{ + struct auth_request_handler *handler = *_handler; + + *_handler = NULL; + + i_assert(!handler->destroyed); + + handler->destroyed = TRUE; + auth_request_handler_unref(&handler); +} + void auth_request_handler_set(struct auth_request_handler *handler, unsigned int connect_uid, unsigned int client_pid) @@ -225,6 +239,13 @@ struct auth_stream_reply *reply; string_t *str; + if (handler->destroyed) { + /* the client connection was already closed. we can't do + anything but abort this request */ + request->internal_failure = TRUE; + result = AUTH_CLIENT_RESULT_FAILURE; + } + reply = auth_stream_reply_init(pool_datastack_create()); switch (result) { case AUTH_CLIENT_RESULT_CONTINUE: @@ -365,10 +386,12 @@ unsigned int id; buffer_t *buf; + i_assert(!handler->destroyed); + /* <id> <mechanism> [...] */ list = t_strsplit(args, "\t"); if (list[0] == NULL || list[1] == NULL || - str_to_uint(list[0], &id) < 0) { + str_to_uint(list[0], &id) < 0) { i_error("BUG: Authentication client %u " "sent broken AUTH request", handler->client_pid); return FALSE;
--- a/src/auth/auth-request-handler.h Thu Sep 30 17:12:55 2010 +0100 +++ b/src/auth/auth-request-handler.h Thu Sep 30 17:49:17 2010 +0100 @@ -29,6 +29,7 @@ (auth_request_callback_t *)callback, context, \ master_callback) #endif +void auth_request_handler_destroy(struct auth_request_handler **handler); void auth_request_handler_unref(struct auth_request_handler **handler); void auth_request_handler_abort_requests(struct auth_request_handler *handler);