# HG changeset patch # User aman@tmm1.net # Date 1247348654 0 # Node ID 75ef7eab4978c1cb302306001c42da65e6db9731 # Parent bbf5c43e269a6a39df7a570775cf019ac11f6d56 Don't fork a resolver process for IPs. Patch from Aman "tmm1" Gupta. committer: Paul Aurich diff -r bbf5c43e269a -r 75ef7eab4978 ChangeLog --- a/ChangeLog Sat Jul 11 21:28:58 2009 +0000 +++ b/ChangeLog Sat Jul 11 21:44:14 2009 +0000 @@ -32,6 +32,7 @@ * Add support for receiving audio clips on MSN. * Fix a leak when the UI provides its own DNS resolving UI op. (Aman Gupta) + * Don't fork a DNS resolver process to resolve IP addresses. (Aman Gupta) AIM and ICQ: * Preliminary support for a new authentication scheme called diff -r bbf5c43e269a -r 75ef7eab4978 libpurple/dnsquery.c --- a/libpurple/dnsquery.c Sat Jul 11 21:28:58 2009 +0000 +++ b/libpurple/dnsquery.c Sat Jul 11 21:44:14 2009 +0000 @@ -145,6 +145,29 @@ return FALSE; } +static gboolean +resolve_ip(PurpleDnsQueryData *query_data) +{ + struct sockaddr_in sin; + if (inet_aton(query_data->hostname, &sin.sin_addr)) + { + /* + * The given "hostname" is actually an IP address, so we + * don't need to do anything. + */ + GSList *hosts = NULL; + sin.sin_family = AF_INET; + sin.sin_port = htons(query_data->port); + hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin))); + hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin))); + purple_dnsquery_resolved(query_data, hosts); + + return TRUE; + } + + return FALSE; +} + #if defined(PURPLE_DNSQUERY_USE_FORK) /* @@ -616,6 +639,12 @@ query_data = data; query_data->timeout = 0; + if (resolve_ip(query_data)) + { + /* resolve_ip calls purple_dnsquery_resolved */ + return FALSE; + } + if (purple_dnsquery_ui_resolve(query_data)) { /* The UI is handling the resolve; we're done */ @@ -758,7 +787,6 @@ resolve_host(gpointer data) { PurpleDnsQueryData *query_data; - struct sockaddr_in sin; GError *err = NULL; query_data = data; @@ -770,20 +798,7 @@ return FALSE; } - if (inet_aton(query_data->hostname, &sin.sin_addr)) - { - /* - * The given "hostname" is actually an IP address, so we - * don't need to do anything. - */ - GSList *hosts = NULL; - sin.sin_family = AF_INET; - sin.sin_port = htons(query_data->port); - hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin))); - hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin))); - purple_dnsquery_resolved(query_data, hosts); - } - else + if (!resolve_ip(query_data)) { /* * Spin off a separate thread to perform the DNS lookup so