From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Jan_Dj=E4rv?= Newsgroups: gmane.emacs.devel Subject: Re: make-network-process's gethostbyname usage Date: Mon, 27 Aug 2007 13:09:14 +0200 Message-ID: <46D2B0DA.8090402@swipnet.se> References: <87hcmueg90.fsf@myxomop.com> <87veb8orkl.fsf@kfs-lx.testafd.dk> <87d4xb304d.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1188212996 455 80.91.229.12 (27 Aug 2007 11:09:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 27 Aug 2007 11:09:56 +0000 (UTC) Cc: emacs-devel@gnu.org, rms@gnu.org, "Kim F. Storm" To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 27 13:09:54 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IPcTa-0001VH-FK for ged-emacs-devel@m.gmane.org; Mon, 27 Aug 2007 13:09:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IPcTZ-00075b-O4 for ged-emacs-devel@m.gmane.org; Mon, 27 Aug 2007 07:09:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IPcTV-00071u-Ka for emacs-devel@gnu.org; Mon, 27 Aug 2007 07:09:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IPcTU-00071E-TD for emacs-devel@gnu.org; Mon, 27 Aug 2007 07:09:41 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IPcTU-000711-Q2 for emacs-devel@gnu.org; Mon, 27 Aug 2007 07:09:40 -0400 Original-Received: from av8-2-sn3.vrr.skanova.net ([81.228.9.184]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IPcTR-0001LQ-0i; Mon, 27 Aug 2007 07:09:37 -0400 Original-Received: by av8-2-sn3.vrr.skanova.net (Postfix, from userid 502) id DA4F838262; Mon, 27 Aug 2007 13:09:30 +0200 (CEST) Original-Received: from smtp3-2-sn3.vrr.skanova.net (smtp3-2-sn3.vrr.skanova.net [81.228.9.102]) by av8-2-sn3.vrr.skanova.net (Postfix) with ESMTP id 9765A381BA; Mon, 27 Aug 2007 13:09:30 +0200 (CEST) Original-Received: from husetbladh.homeip.net (81-235-205-78-no59.tbcn.telia.com [81.235.205.78]) by smtp3-2-sn3.vrr.skanova.net (Postfix) with ESMTP id F2D1937E45; Mon, 27 Aug 2007 13:09:29 +0200 (CEST) User-Agent: Thunderbird 1.5.0.12 (X11/20070604) In-Reply-To: <87d4xb304d.fsf@stupidchicken.com> X-Detected-Kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:77278 Archived-At: Chong Yidong skrev: > storm@cua.dk (Kim F. Storm) writes: > >> Richard Stallman 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 > + #include > + #include ], > + [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 > + #include > + #include > + #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