]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Another attempt in trying to fix crashed at deinit on pending async auth reques...
authorTimo Sirainen <tss@iki.fi>
Mon, 7 Jun 2010 18:28:15 +0000 (19:28 +0100)
committerTimo Sirainen <tss@iki.fi>
Mon, 7 Jun 2010 18:28:15 +0000 (19:28 +0100)
--HG--
branch : HEAD

src/auth/auth-request-handler.c

index 13d8b884ae00d683da72604b73cd82290175fdc3..097ef69ef21b0f6da2973b8a2bd28d76871626fc 100644 (file)
@@ -62,14 +62,25 @@ auth_request_handler_create(auth_request_callback_t *callback, void *context,
 static void auth_request_handler_unref(struct auth_request_handler **_handler)
 {
         struct auth_request_handler *handler = *_handler;
-       struct hash_iterate_context *iter;
-       void *key, *value;
 
        *_handler = NULL;
        i_assert(handler->refcount > 0);
        if (--handler->refcount > 0)
                return;
 
+       /* notify parent that we're done with all requests */
+       handler->callback(NULL, handler->context);
+
+       hash_table_destroy(&handler->requests);
+       pool_unref(&handler->pool);
+}
+
+static void
+auth_request_handler_destroy_requests(struct auth_request_handler *handler)
+{
+       struct hash_iterate_context *iter;
+       void *key, *value;
+
        iter = hash_table_iterate_init(handler->requests);
        while (hash_table_iterate(iter, &key, &value)) {
                struct auth_request *auth_request = value;
@@ -78,12 +89,7 @@ static void auth_request_handler_unref(struct auth_request_handler **_handler)
                auth_request_unref(&auth_request);
        }
        hash_table_iterate_deinit(&iter);
-
-       /* notify parent that we're done with all requests */
-       handler->callback(NULL, handler->context);
-
-       hash_table_destroy(&handler->requests);
-       pool_unref(&handler->pool);
+       hash_table_clear(handler->requests, TRUE);
 }
 
 void auth_request_handler_destroy(struct auth_request_handler **_handler)
@@ -95,6 +101,7 @@ void auth_request_handler_destroy(struct auth_request_handler **_handler)
        i_assert(!handler->destroyed);
 
        handler->destroyed = TRUE;
+       auth_request_handler_destroy_requests(handler);
        auth_request_handler_unref(&handler);
 }