]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dns-client, lib-http: remove ioloop from struct dns_client_settings.
authorsergey.kitov <sergey.kitov@open-xchange.com>
Wed, 13 Nov 2024 13:23:43 +0000 (15:23 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 19 May 2025 08:07:56 +0000 (08:07 +0000)
src/lib-dns-client/dns-lookup.c
src/lib-dns-client/dns-lookup.h
src/lib-dns-client/test-dns-lookup.c
src/lib-http/http-client-host.c

index c2035b0ffed060e07fc81d01835d4a04c82d198a..03f1cd63850d368cd6b8fa3657ebd5ce49889759 100644 (file)
@@ -398,7 +398,7 @@ struct dns_client *dns_client_init(const struct dns_client_settings *set,
        client->timeout_msecs = set->timeout_msecs;
        client->idle_timeout_msecs = set->idle_timeout_msecs;
        client->clist = connection_list_init(&dns_client_set, &dns_client_vfuncs);
-       client->ioloop = set->ioloop == NULL ? current_ioloop : set->ioloop;
+       client->ioloop = current_ioloop;
        client->path = i_strdup(set->dns_client_socket_path);
        client->conn.event_parent = event_parent;
        connection_init_client_unix(client->clist, &client->conn, client->path);
index f04f8c758df63539c2568e457e31817ed4c452b0..42a740fbc760fa73dcef6c4e28e1801f79d316a8 100644 (file)
@@ -20,9 +20,6 @@ struct dns_client_settings {
        /* Non-zero enables caching for the client, is not supported with
           dns_lookup() or dns_lookup_ptr(). Note that DNS TTL is ignored. */
        unsigned int cache_ttl_secs;
-
-       /* ioloop to run the lookup on (defaults to current_ioloop) */
-       struct ioloop *ioloop;
 };
 
 struct dns_lookup_result {
index 5f937daafbd8261bfb139d1c545f2aa6a9410e0e..18d8b36cf0e989b0943cbaef75e9072f8ac6c8e1 100644 (file)
@@ -169,7 +169,6 @@ static void test_dns_expect_result_ips(const char *name, const char *result)
 {
        const struct dns_client_settings set = {
                .dns_client_socket_path = TEST_SOCKET_NAME,
-               .ioloop = test_server.loop,
                .timeout_msecs = 1000,
        };
        struct dns_lookup *lookup;
@@ -185,7 +184,6 @@ static void test_dns_expect_result_name(const char *name, const char *result)
 {
        const struct dns_client_settings set = {
                .dns_client_socket_path = TEST_SOCKET_NAME,
-               .ioloop = test_server.loop,
                .timeout_msecs = 1000,
        };
        struct dns_lookup *lookup;
@@ -220,7 +218,6 @@ static void test_dns_lookup_timeout(void)
 
        const struct dns_client_settings set = {
                .dns_client_socket_path = TEST_SOCKET_NAME,
-               .ioloop = test_server.loop,
                .timeout_msecs = 1000,
        };
        struct dns_lookup *lookup;
@@ -243,7 +240,6 @@ static void test_dns_lookup_abort(void)
 
        const struct dns_client_settings set = {
                .dns_client_socket_path = TEST_SOCKET_NAME,
-               .ioloop = test_server.loop,
                .timeout_msecs = 1000,
        };
        struct dns_lookup *lookup;
@@ -273,7 +269,6 @@ static void test_dns_lookup_cached(void)
        create_dns_server(&test_server);
        const struct dns_client_settings set = {
                .dns_client_socket_path = TEST_SOCKET_NAME,
-               .ioloop = test_server.loop,
                .timeout_msecs = 1000,
                .cache_ttl_secs = 4,
        };
index 098855fefcf7722d0765da5ef738e44ec9aae173..4f9116f2b8246d7229e831ef7e8c6bfc7f4e0959 100644 (file)
@@ -156,15 +156,17 @@ http_client_host_shared_lookup(struct http_client_host_shared *hshared)
                                        http_client_host_shared_dns_callback,
                                        hshared, &hshared->dns_lookup);
        } else if (cctx->dns_client_socket_path != NULL) {
+               struct ioloop *prev_ioloop = current_ioloop;
                i_assert(cctx->dns_lookup_timeout_msecs > 0);
                e_debug(hshared->event, "Performing asynchronous DNS lookup");
                i_zero(&dns_set);
                dns_set.dns_client_socket_path = cctx->dns_client_socket_path;
                dns_set.timeout_msecs = cctx->dns_lookup_timeout_msecs;
-               dns_set.ioloop = cctx->ioloop;
+               io_loop_set_current(cctx->ioloop);
                (void)dns_lookup(hshared->name, &dns_set, hshared->event,
                                 http_client_host_shared_dns_callback,
                                 hshared, &hshared->dns_lookup);
+               io_loop_set_current(prev_ioloop);
        } else {
                struct ip_addr *ips;
                unsigned int ips_count;