pidgin: 07dd0a6e: Don't fork a resolver process for IPs.

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sat Jul 11 17:45:23 EDT 2009


-----------------------------------------------------------------
Revision: 07dd0a6e48616c4c29672a2d21f91600a52855cf
Ancestor: 7560694d015e08baebe1dca2f623d653da1d52af
Author: aman at tmm1.net
Date: 2009-07-11T21:44:14
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/07dd0a6e48616c4c29672a2d21f91600a52855cf

Modified files:
        ChangeLog libpurple/dnsquery.c

ChangeLog: 

Don't fork a resolver process for IPs.

Patch from Aman "tmm1" Gupta.

-------------- next part --------------
============================================================
--- ChangeLog	b7b872e9fc86c18b1a5267f93d1ccb3239203b64
+++ ChangeLog	8afbea44c678351b36d1568d69eba022d17d5a19
@@ -32,6 +32,7 @@ version 2.6.0 (??/??/2009):
 	* 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
============================================================
--- libpurple/dnsquery.c	9e3d25b76b54c879b7fdad836c112d94a20424cf
+++ libpurple/dnsquery.c	0c9bbe3c992ca5b5f170e0d83972961b7f588827
@@ -145,6 +145,29 @@ purple_dnsquery_ui_resolve(PurpleDnsQuer
 	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 @@ resolve_host(gpointer data)
 	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)
 resolve_host(gpointer data)
 {
 	PurpleDnsQueryData *query_data;
-	struct sockaddr_in sin;
 	GError *err = NULL;
 
 	query_data = data;
@@ -770,22 +798,9 @@ resolve_host(gpointer data)
 		return FALSE;
 	}
 
-	if (inet_aton(query_data->hostname, &sin.sin_addr))
+	if (!resolve_ip(query_data))
 	{
 		/*
-		 * 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
-	{
-		/*
 		 * Spin off a separate thread to perform the DNS lookup so
 		 * that we don't block the UI.
 		 */


More information about the Commits mailing list