diff options
| author | Jan Djärv | 2007-11-18 17:34:03 +0000 |
|---|---|---|
| committer | Jan Djärv | 2007-11-18 17:34:03 +0000 |
| commit | 3d66b985763e1a4bff4555e39d08c373d37d2001 (patch) | |
| tree | f9cb0130b7260bcb7082a4ad2a41815bb445d46b /src | |
| parent | 33a2a872544f8111c846bcd34afd06dba4fd7421 (diff) | |
| download | emacs-3d66b985763e1a4bff4555e39d08c373d37d2001.tar.gz emacs-3d66b985763e1a4bff4555e39d08c373d37d2001.zip | |
(init_system_name): Use getaddrinfo if available.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 04fa6aa9357..cf1c42f73c9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2007-11-18 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | 1 | 2007-11-18 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> |
| 2 | 2 | ||
| 3 | * sysdep.c (init_system_name): Use getaddrinfo if available. | ||
| 4 | |||
| 3 | * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_handle_click) | 5 | * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_handle_click) |
| 4 | (x_scroll_bar_note_movement): start, end, with, height in struct | 6 | (x_scroll_bar_note_movement): start, end, with, height in struct |
| 5 | scroll_bar are integers and not Lisp_Object, so remove XINT for them. | 7 | scroll_bar are integers and not Lisp_Object, so remove XINT for them. |
diff --git a/src/sysdep.c b/src/sysdep.c index 35a107f34cf..81850919dd3 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2518,10 +2518,50 @@ init_system_name () | |||
| 2518 | #endif /* not CANNOT_DUMP */ | 2518 | #endif /* not CANNOT_DUMP */ |
| 2519 | if (! index (hostname, '.')) | 2519 | if (! index (hostname, '.')) |
| 2520 | { | 2520 | { |
| 2521 | struct hostent *hp; | ||
| 2522 | int count; | 2521 | int count; |
| 2522 | #ifdef HAVE_GETADDRINFO | ||
| 2523 | struct addrinfo *res; | ||
| 2524 | struct addrinfo hints; | ||
| 2525 | int ret; | ||
| 2526 | |||
| 2527 | memset (&hints, 0, sizeof(hints)); | ||
| 2528 | hints.ai_socktype = SOCK_STREAM; | ||
| 2529 | hints.ai_flags = AI_CANONNAME; | ||
| 2530 | |||
| 2523 | for (count = 0;; count++) | 2531 | for (count = 0;; count++) |
| 2524 | { | 2532 | { |
| 2533 | if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0 | ||
| 2534 | || ret != EAI_AGAIN) | ||
| 2535 | break; | ||
| 2536 | |||
| 2537 | if (count >= 5) | ||
| 2538 | break; | ||
| 2539 | Fsleep_for (make_number (1), Qnil); | ||
| 2540 | } | ||
| 2541 | |||
| 2542 | if (ret == 0) | ||
| 2543 | { | ||
| 2544 | struct addrinfo *it = res; | ||
| 2545 | while (it) | ||
| 2546 | { | ||
| 2547 | char *fqdn = it->ai_canonname; | ||
| 2548 | if (fqdn && index (fqdn, '.') | ||
| 2549 | && strcmp (fqdn, "localhost.localdomain") != 0) | ||
| 2550 | break; | ||
| 2551 | it = it->ai_next; | ||
| 2552 | } | ||
| 2553 | if (it) | ||
| 2554 | { | ||
| 2555 | hostname = alloca (strlen (it->ai_canonname) + 1); | ||
| 2556 | strcpy (hostname, it->ai_canonname); | ||
| 2557 | } | ||
| 2558 | freeaddrinfo (res); | ||
| 2559 | } | ||
| 2560 | #else /* !HAVE_GETADDRINFO */ | ||
| 2561 | struct hostent *hp; | ||
| 2562 | for (count = 0;; count++) | ||
| 2563 | { | ||
| 2564 | |||
| 2525 | #ifdef TRY_AGAIN | 2565 | #ifdef TRY_AGAIN |
| 2526 | h_errno = 0; | 2566 | h_errno = 0; |
| 2527 | #endif | 2567 | #endif |
| @@ -2529,11 +2569,14 @@ init_system_name () | |||
| 2529 | #ifdef TRY_AGAIN | 2569 | #ifdef TRY_AGAIN |
| 2530 | if (! (hp == 0 && h_errno == TRY_AGAIN)) | 2570 | if (! (hp == 0 && h_errno == TRY_AGAIN)) |
| 2531 | #endif | 2571 | #endif |
| 2572 | |||
| 2532 | break; | 2573 | break; |
| 2574 | |||
| 2533 | if (count >= 5) | 2575 | if (count >= 5) |
| 2534 | break; | 2576 | break; |
| 2535 | Fsleep_for (make_number (1), Qnil); | 2577 | Fsleep_for (make_number (1), Qnil); |
| 2536 | } | 2578 | } |
| 2579 | |||
| 2537 | if (hp) | 2580 | if (hp) |
| 2538 | { | 2581 | { |
| 2539 | char *fqdn = (char *) hp->h_name; | 2582 | char *fqdn = (char *) hp->h_name; |
| @@ -2567,6 +2610,7 @@ init_system_name () | |||
| 2567 | } | 2610 | } |
| 2568 | #endif | 2611 | #endif |
| 2569 | } | 2612 | } |
| 2613 | #endif /* !HAVE_GETADDRINFO */ | ||
| 2570 | } | 2614 | } |
| 2571 | #endif /* HAVE_SOCKETS */ | 2615 | #endif /* HAVE_SOCKETS */ |
| 2572 | /* We used to try using getdomainname here, | 2616 | /* We used to try using getdomainname here, |