]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
src: Remove event_parent from struct dns_client_settings.
authorsergey.kitov <sergey.kitov@open-xchange.com>
Mon, 21 Oct 2024 13:57:18 +0000 (16:57 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 19 May 2025 08:07:56 +0000 (08:07 +0000)
12 files changed:
src/auth/auth.c
src/lib-dns-client/dns-lookup.c
src/lib-dns-client/dns-lookup.h
src/lib-dns-client/test-dns-lookup.c
src/lib-doveadm/doveadm-client.c
src/lib-http/http-client-host.c
src/lib-http/test-http-client.c
src/lib-imap-client/imapc-connection.c
src/lib-lua/test-dns-lua.c
src/lib-program-client/program-client-remote.c
src/lib-smtp/smtp-client-connection.c
src/lib-storage/index/pop3c/pop3c-client.c

index 7bfde36594994939793187f2f848090d7ad5dedf..0f3cc6e3066620b9d5188d8711d8b9c02c137229 100644 (file)
@@ -391,7 +391,7 @@ static void auth_init(struct auth *auth)
        dns_set.idle_timeout_msecs = AUTH_DNS_IDLE_TIMEOUT_MSECS;
        dns_set.cache_ttl_secs = AUTH_DNS_CACHE_TTL_SECS;
 
-       auth->dns_client = dns_client_init(&dns_set);
+       auth->dns_client = dns_client_init(&dns_set, NULL);
 }
 
 static void auth_deinit(struct auth *auth)
index 63c14935c553a9b868e39a5adf24587996cf0324..c2035b0ffed060e07fc81d01835d4a04c82d198a 100644 (file)
@@ -272,13 +272,13 @@ static void dns_lookup_timeout(struct dns_lookup *lookup)
 }
 
 int dns_lookup(const char *host, const struct dns_client_settings *set,
-              dns_lookup_callback_t *callback, void *context,
-              struct dns_lookup **lookup_r)
+              struct event *event_parent, dns_lookup_callback_t *callback,
+              void *context, struct dns_lookup **lookup_r)
 {
        struct dns_client *client;
 
        i_assert(set->cache_ttl_secs == 0);
-       client = dns_client_init(set);
+       client = dns_client_init(set, event_parent);
        client->deinit_client_at_free = TRUE;
        return dns_client_lookup(client, host, client->conn.event, callback,
                                 context, lookup_r);
@@ -286,13 +286,14 @@ int dns_lookup(const char *host, const struct dns_client_settings *set,
 
 int dns_lookup_ptr(const struct ip_addr *ip,
                   const struct dns_client_settings *set,
+                  struct event *event_parent,
                   dns_lookup_callback_t *callback, void *context,
                   struct dns_lookup **lookup_r)
 {
        struct dns_client *client;
 
        i_assert(set->cache_ttl_secs == 0);
-       client = dns_client_init(set);
+       client = dns_client_init(set, event_parent);
        client->deinit_client_at_free = TRUE;
        return dns_client_lookup_ptr(client, ip, client->conn.event,
                                     callback, context, lookup_r);
@@ -386,7 +387,8 @@ static const struct connection_settings dns_client_set = {
        .client = TRUE,
 };
 
-struct dns_client *dns_client_init(const struct dns_client_settings *set)
+struct dns_client *dns_client_init(const struct dns_client_settings *set,
+                                  struct event *event_parent)
 {
        struct dns_client *client;
 
@@ -398,7 +400,7 @@ struct dns_client *dns_client_init(const struct dns_client_settings *set)
        client->clist = connection_list_init(&dns_client_set, &dns_client_vfuncs);
        client->ioloop = set->ioloop == NULL ? current_ioloop : set->ioloop;
        client->path = i_strdup(set->dns_client_socket_path);
-       client->conn.event_parent=set->event_parent;
+       client->conn.event_parent = event_parent;
        connection_init_client_unix(client->clist, &client->conn, client->path);
        event_add_category(client->conn.event, &event_category_dns);
        if (set->cache_ttl_secs > 0) {
index 3a3b133fbc5c1c85ff416d49d7faa632125964fd..f04f8c758df63539c2568e457e31817ed4c452b0 100644 (file)
@@ -23,7 +23,6 @@ struct dns_client_settings {
 
        /* ioloop to run the lookup on (defaults to current_ioloop) */
        struct ioloop *ioloop;
-       struct event *event_parent;
 };
 
 struct dns_lookup_result {
@@ -50,29 +49,33 @@ typedef void dns_lookup_callback_t(const struct dns_lookup_result *result,
    When failing with -1, the callback is called before returning from the
    function. */
 int dns_lookup(const char *host, const struct dns_client_settings *set,
+              struct event *event_parent,
               dns_lookup_callback_t *callback, void *context,
               struct dns_lookup **lookup_r) ATTR_NULL(4);
-#define dns_lookup(host, set, callback, context, lookup_r) \
+#define dns_lookup(host, set, event_parent, callback, context, lookup_r) \
        dns_lookup(host - \
                CALLBACK_TYPECHECK(callback, void (*)( \
                        const struct dns_lookup_result *, typeof(context))), \
-               set, (dns_lookup_callback_t *)callback, context, lookup_r)
+               set, event_parent, (dns_lookup_callback_t *)callback, context, lookup_r)
 int dns_lookup_ptr(const struct ip_addr *ip,
                   const struct dns_client_settings *set,
+                  struct event *event_parent,
                   dns_lookup_callback_t *callback, void *context,
                   struct dns_lookup **lookup_r) ATTR_NULL(4);
-#define dns_lookup_ptr(host, set, callback, context, lookup_r) \
+#define dns_lookup_ptr(host, set, event_parent, callback, context, lookup_r) \
        dns_lookup_ptr(host - \
                CALLBACK_TYPECHECK(callback, void (*)( \
                        const struct dns_lookup_result *, typeof(context))), \
-               set, (dns_lookup_callback_t *)callback, context, lookup_r)
+               set, event_parent, \
+               (dns_lookup_callback_t *)callback, context, lookup_r)
 /* Abort the DNS lookup without calling the callback. */
 void dns_lookup_abort(struct dns_lookup **lookup);
 
 void dns_lookup_switch_ioloop(struct dns_lookup *lookup);
 
 /* Alternative API for clients that need to do multiple DNS lookups. */
-struct dns_client *dns_client_init(const struct dns_client_settings *set);
+struct dns_client *dns_client_init(const struct dns_client_settings *set,
+                                  struct event *event_parent);
 void dns_client_deinit(struct dns_client **client);
 
 /* Connect immediately to the dns-lookup socket. */
index 549b04add96a38dca84fc3fc5acd88aa2324736e..5f937daafbd8261bfb139d1c545f2aa6a9410e0e 100644 (file)
@@ -177,7 +177,7 @@ static void test_dns_expect_result_ips(const char *name, const char *result)
                .ret = result == NULL ? -1 : 0,
                .result = result
        };
-       test_assert(dns_lookup(name, &set, test_callback_ips, &ctx, &lookup) == 0);
+       test_assert(dns_lookup(name, &set, NULL, test_callback_ips, &ctx, &lookup) == 0);
        io_loop_run(test_server.loop);
 }
 
@@ -195,7 +195,7 @@ static void test_dns_expect_result_name(const char *name, const char *result)
        };
        struct ip_addr addr;
        i_assert(net_addr2ip(name, &addr) == 0);
-       test_assert(dns_lookup_ptr(&addr, &set, test_callback_name, &ctx, &lookup) == 0);
+       test_assert(dns_lookup_ptr(&addr, &set, NULL, test_callback_name, &ctx, &lookup) == 0);
        io_loop_run(test_server.loop);
 }
 
@@ -229,7 +229,7 @@ static void test_dns_lookup_timeout(void)
                .result = NULL,
        };
 
-       test_assert(dns_lookup("waitfor1500", &set, test_callback_ips, &ctx, &lookup) == 0);
+       test_assert(dns_lookup("waitfor1500", &set, NULL, test_callback_ips, &ctx, &lookup) == 0);
        io_loop_run(current_ioloop);
 
        destroy_dns_server(&test_server);
@@ -252,7 +252,7 @@ static void test_dns_lookup_abort(void)
                .result = NULL,
        };
 
-       test_assert(dns_lookup("waitfor1500", &set, test_callback_ips, &ctx, &lookup) == 0);
+       test_assert(dns_lookup("waitfor1500", &set, NULL, test_callback_ips, &ctx, &lookup) == 0);
        struct timeout *to = timeout_add_short(100, io_loop_stop, current_ioloop);
        io_loop_run(current_ioloop);
        timeout_remove(&to);
@@ -276,11 +276,10 @@ static void test_dns_lookup_cached(void)
                .ioloop = test_server.loop,
                .timeout_msecs = 1000,
                .cache_ttl_secs = 4,
-               .event_parent = event,
        };
 
 
-       struct dns_client *client = dns_client_init(&set);
+       struct dns_client *client = dns_client_init(&set, event);
 
        /* lookup localhost */
        ctx.result = "127.0.0.1\t::1";
index b2823e2e9294df4adc69dfd47b7b2b00c33f2ff2..24f136574123d9525a21ff6f38ece8a6b5eaf3d3 100644 (file)
@@ -719,11 +719,10 @@ static int doveadm_client_dns_lookup(struct doveadm_client *conn,
        i_zero(&dns_set);
        dns_set.dns_client_socket_path = conn->set.dns_client_socket_path;
        dns_set.timeout_msecs = DOVEADM_CLIENT_DNS_TIMEOUT_MSECS;
-       dns_set.event_parent = conn->conn.event;
 
        ctx->conn = conn;
 
-       if (dns_lookup(conn->set.hostname, &dns_set,
+       if (dns_lookup(conn->set.hostname, &dns_set, conn->conn.event,
                       doveadm_client_dns_lookup_callback, ctx,
                       &conn->dns_lookup) != 0) {
                *error_r = t_strdup(ctx->error);
index 8541ef6301cad3347c4dae839970f9d185f97b52..098855fefcf7722d0765da5ef738e44ec9aae173 100644 (file)
@@ -162,10 +162,9 @@ http_client_host_shared_lookup(struct http_client_host_shared *hshared)
                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;
-               dns_set.event_parent = hshared->event;
-               (void)dns_lookup(hshared->name, &dns_set,
-                                http_client_host_shared_dns_callback, hshared,
-                                &hshared->dns_lookup);
+               (void)dns_lookup(hshared->name, &dns_set, hshared->event,
+                                http_client_host_shared_dns_callback,
+                                hshared, &hshared->dns_lookup);
        } else {
                struct ip_addr *ips;
                unsigned int ips_count;
index 1f8fa4c3dfc249dc4b3cd71b55f27f4ba06de13c..9c317396247a4bef665f9c4d35b2c4cd83c6f388 100644 (file)
@@ -373,7 +373,7 @@ int main(int argc, char *argv[])
 
        /* check if there is a DNS client */
        if (access(dns_set.dns_client_socket_path, R_OK|W_OK) == 0) {
-               dns_client = dns_client_init(&dns_set);
+               dns_client = dns_client_init(&dns_set, NULL);
 
                if (dns_client_connect(dns_client, &error) < 0)
                        i_fatal("Couldn't initialize DNS client: %s", error);
index 0073e5144c1f90d0a0bc0fa90521714a16dfd49b..fcf5e75ba2a45416fe9d31954f670a6b8e567bbc 100644 (file)
@@ -1955,7 +1955,6 @@ void imapc_connection_connect(struct imapc_connection *conn)
        i_zero(&dns_set);
        dns_set.dns_client_socket_path = conn->client->dns_client_socket_path;
        dns_set.timeout_msecs = conn->client->set->imapc_connection_timeout_interval_msecs;
-       dns_set.event_parent = conn->event;
 
        imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_CONNECTING);
        if (conn->ips_count > 0) {
@@ -1983,8 +1982,8 @@ void imapc_connection_connect(struct imapc_connection *conn)
                memcpy(conn->ips, ips, ips_count * sizeof(*ips));
        } else {
                (void)dns_lookup(conn->client->set->imapc_host, &dns_set,
-                                imapc_connection_dns_callback, conn,
-                                &conn->dns_lookup);
+                                conn->event, imapc_connection_dns_callback,
+                                conn, &conn->dns_lookup);
                return;
        }
        imapc_connection_connect_next_ip(conn);
index e4f3c50e8c4c726d256fa5a268c3fc0c9a3b24ec..68ff3aa9989b3d64bd433b5744d008259ba62dc4 100644 (file)
@@ -46,7 +46,7 @@ static void test_dns_lua_common(const char *luascript)
        struct settings_simple test_set;
        settings_simple_init(&test_set, NULL);
 
-       struct dns_client *client = dns_client_init(&set);
+       struct dns_client *client = dns_client_init(&set, NULL);
 
        struct dlua_script *script;
        const char *error;
index bf6926cbdee6c6ff54bae9d3060f48fc9877b5c0..804509cfd322743d417fd8556cc4de3677c0c89a 100644 (file)
@@ -532,8 +532,8 @@ static int program_client_net_connect_init(struct program_client *pclient)
                                pclient->params.dns_client_socket_path;
                        prclient->dns_set.timeout_msecs =
                                pclient->params.client_connect_timeout_msecs;
-                       prclient->dns_set.event_parent = pclient->event;
                        (void)dns_lookup(prclient->address, &prclient->dns_set,
+                                        pclient->event,
                                         program_client_net_connect_resolved,
                                         prclient, &prclient->lookup);
                        return 0;
index 2683da8d6b7b7d70b3de8f1418185a9f707cf7d0..5c095f9502ac397a8c75f8b1f4bb247b2ac77860 100644 (file)
@@ -1897,9 +1897,8 @@ smtp_client_connection_lookup_ip(struct smtp_client_connection *conn)
                dns_set.dns_client_socket_path =
                        conn->set.dns_client_socket_path;
                dns_set.timeout_msecs = conn->set.connect_timeout_msecs;
-               dns_set.event_parent = conn->event;
                e_debug(conn->event, "Performing asynchronous DNS lookup");
-               (void)dns_lookup(conn->host, &dns_set,
+               (void)dns_lookup(conn->host, &dns_set, conn->event,
                                 smtp_client_connection_dns_callback, conn,
                                 &conn->dns_lookup);
        } else {
index 5ca6b13b4f04773b20568d803f27dd336ad3bdec..1b893c3c001b602ffc721a0956ff6e592ed54175 100644 (file)
@@ -265,8 +265,7 @@ static int pop3c_client_dns_lookup(struct pop3c_client *client)
                dns_set.dns_client_socket_path =
                        client->set.dns_client_socket_path;
                dns_set.timeout_msecs = POP3C_DNS_LOOKUP_TIMEOUT_MSECS;
-               dns_set.event_parent = client->event;
-               if (dns_lookup(client->set.host, &dns_set,
+               if (dns_lookup(client->set.host, &dns_set, client->event,
                               pop3c_dns_callback, client,
                               &client->dns_lookup) < 0)
                        return -1;