From: "Jan Djärv" <jan.h.d@swipnet.se>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-devel@gnu.org, rms@gnu.org, "Kim F. Storm" <storm@cua.dk>
Subject: Re: make-network-process's gethostbyname usage
Date: Mon, 27 Aug 2007 13:09:14 +0200 [thread overview]
Message-ID: <46D2B0DA.8090402@swipnet.se> (raw)
In-Reply-To: <87d4xb304d.fsf@stupidchicken.com>
Chong Yidong skrev:
> storm@cua.dk (Kim F. Storm) writes:
>
>> Richard Stallman <rms@gnu.org> writes:
>>
>>> make-network-process calles gethostbyname, but never calls
>>> res_init. The problem, which appears is: if contents of
>>> /etc/resolv.conf was changed old dns servers are unavailable,
>>> gethostbyname still tries them, not new ones. So this bug is pretty
>>> much the same as http://bugs.debian.org/438680 (which has a patch).
>>>
>>> Would someone please DTRT about this, then ack?
>>> It needs to be fixed in Emacs 22.
>> I don't know what to do about this.
>>
>> configure already has a check for res_init, but on my system (GNU/Linux),
>> HAVE_RES_INIT is undefined, indicating that it doesn't exist.
>>
>> However, I believe that it does exist, but only if -lresolv is specified.
>>
>> So how can we fix configure to DTRT?
>
> See the attached patch.
>
> Strangely enough, even though autoconf needs -lresolv to detect
> res_init(), it doesn't seem as though we need to add -lresolv when
> compiling Emacs itself. I don't know why this should be the case.
> Does anyone have an idea?
Probably some magic in GNU libc, I would not rely on this working on other
systems that don't use GNU libc and/or linker.
You should use the predefined macros instead of using AC_TRY_LINK, in this
case AC_CHECK_LIB.
Jan D.
>
> *** emacs/configure.in.~1.444.2.2.~ 2007-08-22 17:50:31.000000000 -0400
> --- emacs/configure.in 2007-08-25 14:34:43.000000000 -0400
> ***************
> *** 2580,2586 ****
>
> AC_CHECK_FUNCS(gethostname getdomainname dup2 \
> rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \
> ! random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime res_init setsid \
> strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \
> utimes setrlimit setpgid getcwd getwd shutdown getaddrinfo \
> __fpending mblen mbrlen mbsinit strsignal setitimer ualarm index rindex \
> --- 2580,2586 ----
>
> AC_CHECK_FUNCS(gethostname getdomainname dup2 \
> rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \
> ! random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime setsid \
> strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \
> utimes setrlimit setpgid getcwd getwd shutdown getaddrinfo \
> __fpending mblen mbrlen mbsinit strsignal setitimer ualarm index rindex \
> ***************
> *** 2624,2640 ****
> # than to expect to find it in ncurses.
> AC_CHECK_LIB(ncurses, tparm)
>
> # Do we need the Hesiod library to provide the support routines?
> if test "$with_hesiod" = yes ; then
> # Don't set $LIBS here -- see comments above.
> - resolv=no
> AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
> [AC_CHECK_LIB(resolv, res_send, resolv=yes,
> [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
> if test "$resolv" = yes ; then
> RESOLVLIB=-lresolv
> - AC_DEFINE(HAVE_LIBRESOLV, 1,
> - [Define to 1 if you have the resolv library (-lresolv).])
> else
> RESOLVLIB=
> fi
> --- 2624,2662 ----
> # than to expect to find it in ncurses.
> AC_CHECK_LIB(ncurses, tparm)
>
> + resolv=no
> +
> + # Do we have res_init, for detecting changes in /etc/resolv.conf?
> +
> + AC_CHECK_FUNC(res_init, have_res_init=yes, have_res_init=no)
> + if test "$have_res_init" = no; then
> + OLIBS="$LIBS"
> + LIBS="$LIBS -lresolv"
> + AC_MSG_CHECKING(for res_init with -lresolv)
> + AC_TRY_LINK([#include <netinet/in.h>
> + #include <arpa/nameser.h>
> + #include <resolv.h> ],
> + [res_init();],
> + have_res_init=yes, have_res_init=no)
> + AC_MSG_RESULT($have_res_init)
> + if test "$have_res_init" = yes ; then
> + resolv=yes
> + fi
> + LIBS="$OLIBS"
> + fi
> +
> + if test "$have_res_init" = yes; then
> + AC_DEFINE(HAVE_RES_INIT, 1, [Define to 1 if res_init is available.])
> + fi
> +
> # Do we need the Hesiod library to provide the support routines?
> if test "$with_hesiod" = yes ; then
> # Don't set $LIBS here -- see comments above.
> AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
> [AC_CHECK_LIB(resolv, res_send, resolv=yes,
> [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
> if test "$resolv" = yes ; then
> RESOLVLIB=-lresolv
> else
> RESOLVLIB=
> fi
> ***************
> *** 2644,2649 ****
> --- 2666,2677 ----
> :, $RESOLVLIB)])
> fi
>
> + # Do we need libresolv (due to res_init or Hesiod)?
> + if test "$resolv" = yes ; then
> + AC_DEFINE(HAVE_LIBRESOLV, 1,
> + [Define to 1 if you have the resolv library (-lresolv).])
> + fi
> +
> # These tell us which Kerberos-related libraries to use.
> if test "${with_kerberos+set}" = set; then
> AC_CHECK_LIB(com_err, com_err)
> *** emacs/src/process.c.~1.512.2.4.~ 2007-08-08 14:07:26.000000000 -0400
> --- emacs/src/process.c 2007-08-25 14:56:59.000000000 -0400
> ***************
> *** 129,134 ****
> --- 129,140 ----
> # endif
> #endif
>
> + #ifdef HAVE_RES_INIT
> + #include <netinet/in.h>
> + #include <arpa/nameser.h>
> + #include <resolv.h>
> + #endif
> +
> #include "lisp.h"
> #include "systime.h"
> #include "systty.h"
> ***************
> *** 3082,3087 ****
> --- 3088,3098 ----
> hints.ai_family = family;
> hints.ai_socktype = socktype;
> hints.ai_protocol = 0;
> +
> + #ifdef HAVE_RES_INIT
> + res_init ();
> + #endif
> +
> ret = getaddrinfo (SDATA (host), portstring, &hints, &res);
> if (ret)
> #ifdef HAVE_GAI_STRERROR
> ***************
> *** 3127,3132 ****
> --- 3138,3148 ----
> as it may `hang' Emacs for a very long time. */
> immediate_quit = 1;
> QUIT;
> +
> + #ifdef HAVE_RES_INIT
> + res_init ();
> + #endif
> +
> host_info_ptr = gethostbyname (SDATA (host));
> immediate_quit = 0;
>
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
prev parent reply other threads:[~2007-08-27 11:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-20 8:56 make-network-process's gethostbyname usage Alexander Kotelnikov
2007-08-21 8:43 ` Kim F. Storm
2007-08-21 9:51 ` Alexander Kotelnikov
2007-08-21 14:46 ` Richard Stallman
2007-08-22 9:18 ` Kim F. Storm
2007-08-22 11:32 ` Jan Djärv
2007-08-23 0:45 ` Richard Stallman
2007-08-25 19:06 ` Chong Yidong
2007-08-27 11:09 ` Jan Djärv [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46D2B0DA.8090402@swipnet.se \
--to=jan.h.d@swipnet.se \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
--cc=storm@cua.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.