summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2016-04-20 17:07:53 -0400
committerRay Strode <rstrode@redhat.com>2017-03-03 15:32:41 -0500
commit9c5209f83f9bb3aebf63e1a8e50e6893c83570b2 (patch)
tree5a13eae0786032aad521a19d1c6157be65cc1260
parent9f0a6c7e3a417db385b4d28285f7f26c0f80ca94 (diff)
downloadgdm-9c5209f83f9bb3aebf63e1a8e50e6893c83570b2.tar.gz
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
-rw-r--r--common/gdm-address.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/common/gdm-address.c b/common/gdm-address.c
index 34480380..a8b73e28 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;