[gdm/gnome-3-22] common: limit potentially expensive name lookups



commit 9c5209f83f9bb3aebf63e1a8e50e6893c83570b2
Author: Ray Strode <rstrode redhat com>
Date:   Wed Apr 20 17:07:53 2016 -0400

    common: limit potentially expensive name lookups
    
    Right now we're doing name look ups when we don't have to.  These
    name look ups can cause lengthy timeouts in misconfigured environments.
    
    This commit reduces the name looks used by GDM to make it more resiliant
    to failure.
    
    Ported from RHEL 6 to RHEL 7 by Ashish Shah <ashishks redhat com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779499

 common/gdm-address.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/common/gdm-address.c b/common/gdm-address.c
index 3448038..a8b73e2 100644
--- a/common/gdm-address.c
+++ b/common/gdm-address.c
@@ -220,14 +220,13 @@ address_family_str (GdmAddress *address)
 
 static void
 _gdm_address_debug (GdmAddress *address,
-                    const char *hostname,
                     const char *host,
                     const char *port)
 {
-        g_debug ("Address family:%d (%s) hostname:%s host:%s port:%s local:%d loopback:%d",
+        g_debug ("Address family:%d (%s) host:%s port:%s local:%d loopback:%d",
+
                  address->ss->ss_family,
                  address_family_str (address) ? address_family_str (address) : "(null)",
-                 hostname ? hostname : "(null)",
                  host ? host : "(null)",
                  port ? port : "(null)",
                  gdm_address_is_local (address),
@@ -237,13 +236,14 @@ _gdm_address_debug (GdmAddress *address,
 void
 gdm_address_debug (GdmAddress *address)
 {
-        char *hostname;
-        char *host;
-        char *port;
+        char *hostname = NULL;
+        char *host = NULL;
+        char *port = NULL;
 
-        gdm_address_get_hostname (address, &hostname);
         gdm_address_get_numeric_info (address, &host, &port);
 
+        _gdm_address_debug (address, host, port);
+
         g_free (hostname);
         g_free (host);
         g_free (port);
@@ -277,7 +277,8 @@ gdm_address_get_hostname (GdmAddress *address,
                 err_msg = gai_strerror (res);
                 g_warning ("Unable to lookup hostname: %s",
                         err_msg ? err_msg : "(null)");
-                _gdm_address_debug (address, NULL, NULL, NULL);
+                _gdm_address_debug (address, NULL, NULL);
+
         }
 
         /* try numeric? */
@@ -318,7 +319,7 @@ gdm_address_get_numeric_info (GdmAddress *address,
                 err_msg = gai_strerror (res);
                 g_warning ("Unable to lookup numeric info: %s",
                         err_msg ? err_msg : "(null)");
-                _gdm_address_debug (address, NULL, NULL, NULL);
+                _gdm_address_debug (address, NULL, NULL);
         } else {
                 ret = TRUE;
         }
@@ -404,8 +405,6 @@ add_local_siocgifconf (GList **list)
                                         address = gdm_address_new_from_sockaddr ((struct sockaddr 
*)&ifreq.ifr_addr,
                                                                                  sizeof (struct sockaddr));
 
-                                        gdm_address_debug (address);
-
                                         *list = g_list_append (*list, address);
                                 }
                         }
@@ -437,7 +436,8 @@ add_local_addrinfo (GList **list)
 
         memset (&hints, 0, sizeof (hints));
         hints.ai_family = AF_UNSPEC;
-        hints.ai_flags = AI_CANONNAME;
+        hints.ai_flags = AI_CANONNAME | AI_NUMERICHOST;
+
 
         g_debug ("GdmAddress: looking up hostname: %s", hostbuf);
         result = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]