Mercurial > pidgin
changeset 27478:75ef7eab4978
Don't fork a resolver process for IPs.
Patch from Aman "tmm1" Gupta.
committer: Paul Aurich <paul@darkrain42.org>
author | aman@tmm1.net |
---|---|
date | Sat, 11 Jul 2009 21:44:14 +0000 |
parents | bbf5c43e269a |
children | 5345dfe48272 |
files | ChangeLog libpurple/dnsquery.c |
diffstat | 2 files changed, 31 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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