1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

Fix previous patch to match its commit message

This commit is contained in:
Paul Eggert 2014-12-29 12:39:58 -08:00
parent f9acac751d
commit 973110680c
8 changed files with 30 additions and 138 deletions

View file

@ -1406,17 +1406,6 @@ setup_pty (int fd)
}
#endif /* HAVE_PTYS */
#ifdef HAVE_SOCKETS
#include <sys/socket.h>
#include <netdb.h>
#endif /* HAVE_SOCKETS */
#ifdef TRY_AGAIN
#ifndef HAVE_H_ERRNO
extern int h_errno;
#endif
#endif /* TRY_AGAIN */
void
init_system_name (void)
{
@ -1447,101 +1436,6 @@ init_system_name (void)
hostname = hostname_alloc = xpalloc (hostname_alloc, &hostname_size, 1,
min (PTRDIFF_MAX, SIZE_MAX), 1);
}
#ifdef HAVE_SOCKETS
/* Turn the hostname into the official, fully-qualified hostname.
Don't do this if we're going to dump; this can confuse system
libraries on some machines and make the dumped emacs core dump. */
#ifndef CANNOT_DUMP
if (initialized)
#endif /* not CANNOT_DUMP */
if (! strchr (hostname, '.'))
{
int count;
#ifdef HAVE_GETADDRINFO
struct addrinfo *res;
struct addrinfo hints;
int ret;
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
for (count = 0;; count++)
{
if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0
|| ret != EAI_AGAIN)
break;
if (count >= 5)
break;
Fsleep_for (make_number (1), Qnil);
}
if (ret == 0)
{
struct addrinfo *it = res;
while (it)
{
char *fqdn = it->ai_canonname;
if (fqdn && strchr (fqdn, '.')
&& strcmp (fqdn, "localhost.localdomain") != 0)
break;
it = it->ai_next;
}
if (it)
{
ptrdiff_t len = strlen (it->ai_canonname);
if (hostname_size <= len)
{
hostname_size = len + 1;
hostname = hostname_alloc = xrealloc (hostname_alloc,
hostname_size);
}
strcpy (hostname, it->ai_canonname);
}
freeaddrinfo (res);
}
#else /* !HAVE_GETADDRINFO */
struct hostent *hp;
for (count = 0;; count++)
{
#ifdef TRY_AGAIN
h_errno = 0;
#endif
hp = gethostbyname (hostname);
#ifdef TRY_AGAIN
if (! (hp == 0 && h_errno == TRY_AGAIN))
#endif
break;
if (count >= 5)
break;
Fsleep_for (make_number (1), Qnil);
}
if (hp)
{
char *fqdn = (char *) hp->h_name;
if (!strchr (fqdn, '.'))
{
/* We still don't have a fully qualified domain name.
Try to find one in the list of alternate names */
char **alias = hp->h_aliases;
while (*alias
&& (!strchr (*alias, '.')
|| !strcmp (*alias, "localhost.localdomain")))
alias++;
if (*alias)
fqdn = *alias;
}
hostname = fqdn;
}
#endif /* !HAVE_GETADDRINFO */
}
#endif /* HAVE_SOCKETS */
#endif /* HAVE_GETHOSTNAME */
char *p;
for (p = hostname; *p; p++)