* make-network-process's gethostbyname usage
@ 2007-08-20 8:56 Alexander Kotelnikov
2007-08-21 8:43 ` Kim F. Storm
2007-08-21 14:46 ` Richard Stallman
0 siblings, 2 replies; 9+ messages in thread
From: Alexander Kotelnikov @ 2007-08-20 8:56 UTC (permalink / raw)
To: emacs-devel
Hello.
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).
--
Alexander Kotelnikov
Saint-Petersburg, Russia
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
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
1 sibling, 1 reply; 9+ messages in thread
From: Kim F. Storm @ 2007-08-21 8:43 UTC (permalink / raw)
To: emacs-devel
Alexander Kotelnikov <sacha@myxomop.com> writes:
> Hello.
>
> 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).
Is res_init available on all platforms which have gethostbyname ?
Otherwise, we need to arrange for configure to test for its
existence...
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
2007-08-21 8:43 ` Kim F. Storm
@ 2007-08-21 9:51 ` Alexander Kotelnikov
0 siblings, 0 replies; 9+ messages in thread
From: Alexander Kotelnikov @ 2007-08-21 9:51 UTC (permalink / raw)
To: emacs-devel
>>>>> On Tue, 21 Aug 2007 10:43:01 +0200
>>>>> "KFS" == Kim F Storm <storm@cua.dk> wrote:
KFS>
KFS> Alexander Kotelnikov <sacha@myxomop.com> writes:
>> Hello.
>>
>> 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).
KFS>
KFS> Is res_init available on all platforms which have gethostbyname ?
I am alsmost sure, no. BTW I think on my linux box getaddrinfo() is
used instead of gethostbyname(), but anyway, res_init is needed. And
its presence really helps: made a hack on emacs22-22.1+1 yesterday at
home and today I had not had to restart my emacs with gnus in the
office.
KFS> Otherwise, we need to arrange for configure to test for its
KFS> existence...
IIRC my fgrep res_init found some occurrences in autoconf/autoheader
emacs files.
--
Alexander Kotelnikov
Saint-Petersburg, Russia
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
2007-08-20 8:56 make-network-process's gethostbyname usage Alexander Kotelnikov
2007-08-21 8:43 ` Kim F. Storm
@ 2007-08-21 14:46 ` Richard Stallman
2007-08-22 9:18 ` Kim F. Storm
1 sibling, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2007-08-21 14:46 UTC (permalink / raw)
To: emacs-devel
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
2007-08-21 14:46 ` Richard Stallman
@ 2007-08-22 9:18 ` Kim F. Storm
2007-08-22 11:32 ` Jan Djärv
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Kim F. Storm @ 2007-08-22 9:18 UTC (permalink / raw)
To: rms; +Cc: emacs-devel
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?
a) Include -lresolv in the check for HAVE_RES_INIT.
b) Include -lresolv in LIBS if and only if HAVE_RES_INIT is defined.
If that is in place, it should be trivial to add
#if HAVE_RES_INIT
res_init();
#endif
before all calls to gethostbyname and getaddrinfo.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
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
2 siblings, 0 replies; 9+ messages in thread
From: Jan Djärv @ 2007-08-22 11:32 UTC (permalink / raw)
To: Kim F. Storm; +Cc: rms, emacs-devel
Kim F. Storm skrev:
> 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?
>
> a) Include -lresolv in the check for HAVE_RES_INIT.
>
> b) Include -lresolv in LIBS if and only if HAVE_RES_INIT is defined.
>
>
Should we not first try if res_init exists without any special libraries, and
if that fails, check for -lresolv and try to find res_init again?
But there seems to be some problem with that, comment in configure.in says:
dnl This causes -lresolv to get used in subsequent tests,
dnl which causes failures on some systems such as HPUX 9.
dnl AC_CHECK_LIB(resolv, gethostbyname)
But otherwise:
AC_CHECK_FUNCS(res_init)
if test "X$HAVE_RES_INIT" = X; then
AC_SEARCH_LIBS(res_init, resolv, HAVE_RES_INIT=yes)
fi
Untested :-)
Jan D.
> If that is in place, it should be trivial to add
>
> #if HAVE_RES_INIT
> res_init();
> #endif
>
> before all calls to gethostbyname and getaddrinfo.
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
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
2 siblings, 0 replies; 9+ messages in thread
From: Richard Stallman @ 2007-08-23 0:45 UTC (permalink / raw)
To: Kim F. Storm; +Cc: emacs-devel
So how can we fix configure to DTRT?
a) Include -lresolv in the check for HAVE_RES_INIT.
We can certainly do that, if that gives the right results.
Do you know of any residual problem that would remain
if that is fixed?
b) Include -lresolv in LIBS if and only if HAVE_RES_INIT is defined.
If that is in place, it should be trivial to add
#if HAVE_RES_INIT
res_init();
#endif
before all calls to gethostbyname and getaddrinfo.
By all means.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
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
2 siblings, 1 reply; 9+ messages in thread
From: Chong Yidong @ 2007-08-25 19:06 UTC (permalink / raw)
To: Kim F. Storm; +Cc: rms, emacs-devel
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?
*** 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;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: make-network-process's gethostbyname usage
2007-08-25 19:06 ` Chong Yidong
@ 2007-08-27 11:09 ` Jan Djärv
0 siblings, 0 replies; 9+ messages in thread
From: Jan Djärv @ 2007-08-27 11:09 UTC (permalink / raw)
To: Chong Yidong; +Cc: emacs-devel, rms, Kim F. Storm
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-08-27 11:09 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).