dovecot-2.1: smtp/lmtp client: If dns-client socket path isn't g...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 28 19:25:40 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/bc2eea348f55
changeset: 14018:bc2eea348f55
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jan 28 19:24:17 2012 +0200
description:
smtp/lmtp client: If dns-client socket path isn't given, use blocking lookup.

diffstat:

 src/lib-lda/lmtp-client.c |  23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 5a14f5ddd1a2 -r bc2eea348f55 src/lib-lda/lmtp-client.c
--- a/src/lib-lda/lmtp-client.c	Sat Jan 28 19:00:56 2012 +0200
+++ b/src/lib-lda/lmtp-client.c	Sat Jan 28 19:24:17 2012 +0200
@@ -538,6 +538,9 @@
 			    const char *host, unsigned int port)
 {
 	struct dns_lookup_settings dns_lookup_set;
+	struct ip_addr *ips;
+	unsigned int ips_count;
+	int ret;
 
 	client->input_state = LMTP_INPUT_STATE_GREET;
 	client->host = p_strdup(client->pool, host);
@@ -554,14 +557,26 @@
 		client->set.dns_client_socket_path;
 	dns_lookup_set.timeout_msecs = LMTP_CLIENT_DNS_LOOKUP_TIMEOUT_MSECS;
 
-	if (net_addr2ip(host, &client->ip) < 0) {
+	if (net_addr2ip(host, &client->ip) == 0) {
+		/* IP address */
+	} else if (dns_lookup_set.dns_client_socket_path == NULL) {
+		/* no dns-client, use blocking lookup */
+		ret = net_gethostbyname(host, &ips, &ips_count);
+		if (ret != 0) {
+			i_error("lmtp client: DNS lookup of %s failed: %s",
+				client->host, net_gethosterror(ret));
+			return -1;
+		}
+		client->ip = ips[0];
+	} else {
 		if (dns_lookup(host, &dns_lookup_set,
 			       lmtp_client_dns_done, client) < 0)
 			return -1;
-	} else {
-		if (lmtp_client_connect(client) < 0)
-			return -1;
+		return 0;
 	}
+
+	if (lmtp_client_connect(client) < 0)
+		return -1;
 	return 0;
 }
 


More information about the dovecot-cvs mailing list