]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dns: Call lookup callback on abort with EAI_CANCELED
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 6 Mar 2025 07:17:24 +0000 (09:17 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 7 Mar 2025 11:25:14 +0000 (13:25 +0200)
src/lib-dns-client/dns-lookup.c
src/lib-dns-client/dns-lookup.h

index 8216626ef1070aa44eeaed0bd2da70a8e762a0a9..cab27cc17301c554879721c975197aca22cc52ac 100644 (file)
@@ -338,8 +338,13 @@ void dns_lookup_abort(struct dns_lookup **_lookup)
        struct dns_client *client = lookup->client;
        if (client->deinit_client_at_free)
                dns_client_deinit(&client);
-       else
+       else if (lookup->callback != NULL) {
+               dns_lookup_save_msecs(lookup);
+               lookup->result.ret = EAI_CANCELED,
+               lookup->result.error = "Lookup canceled";
+               lookup->callback(&lookup->result, lookup->context);
                lookup->callback = NULL;
+       }
 }
 
 static void dns_lookup_switch_ioloop_real(struct dns_lookup *lookup)
index 6e58fcefa7547f689346913f07e2545ae40be04d..5115cb6f7c707deb957edfa1d4e3d6e14b43ddb7 100644 (file)
@@ -1,8 +1,13 @@
 #ifndef DNS_LOOKUP_H
 #define DNS_LOOKUP_H
 
+#include <netdb.h>
+
 #define DNS_CLIENT_SOCKET_NAME "dns-client"
-#define EAI_CANCELED -101
+
+#ifndef EAI_CANCELED
+#  define EAI_CANCELED INT_MIN
+#endif
 
 struct dns_lookup;