[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/sysdep.c,v
From: |
Jan Djärv |
Subject: |
[Emacs-diffs] Changes to emacs/src/sysdep.c,v |
Date: |
Sun, 18 Nov 2007 17:33:55 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Jan Djärv <jhd> 07/11/18 17:33:55
Index: sysdep.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/sysdep.c,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -b -r1.288 -r1.289
--- sysdep.c 27 Sep 2007 21:20:06 -0000 1.288
+++ sysdep.c 18 Nov 2007 17:33:55 -0000 1.289
@@ -2518,10 +2518,50 @@
#endif /* not CANNOT_DUMP */
if (! index (hostname, '.'))
{
- struct hostent *hp;
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 && index (fqdn, '.')
+ && strcmp (fqdn, "localhost.localdomain") != 0)
+ break;
+ it = it->ai_next;
+ }
+ if (it)
+ {
+ hostname = alloca (strlen (it->ai_canonname) + 1);
+ strcpy (hostname, it->ai_canonname);
+ }
+ freeaddrinfo (res);
+ }
+#else /* !HAVE_GETADDRINFO */
+ struct hostent *hp;
+ for (count = 0;; count++)
+ {
+
#ifdef TRY_AGAIN
h_errno = 0;
#endif
@@ -2529,11 +2569,14 @@
#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;
@@ -2567,6 +2610,7 @@
}
#endif
}
+#endif /* !HAVE_GETADDRINFO */
}
#endif /* HAVE_SOCKETS */
/* We used to try using getdomainname here,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/src/sysdep.c,v,
Jan Djärv <=