Subject: Re: pkg/10972: editors/emacs does not work correctly (IPV6 support seems incorrect)
To: Love <lha@stacken.kth.se>
From: None <itojun@iijlab.net>
List: netbsd-bugs
Date: 09/08/2000 20:20:47
>	yes, the above understanding is correct.  IIRC the bug is in emacs
>	side, and there are fixes sent to emacs maintainer.  i'll try to put
>	local patch (patches/patch-xx) for now.

	does it solve the problem?  sorry for "patch of patch".

itojun


? work
Index: files/patch-sum
===================================================================
RCS file: /cvsroot/pkgsrc/editors/emacs/files/patch-sum,v
retrieving revision 1.14
diff -c -1 -r1.14 patch-sum
*** files/patch-sum	2000/08/23 16:20:17	1.14
--- files/patch-sum	2000/09/08 11:19:12
***************
*** 10,12 ****
  MD5 (patch-ai) = 7d171eaaa0489cf4f24fd89fe45fda9e
! MD5 (patch-aj) = 2826479143a847192c969b7e8f623ade
  MD5 (patch-ak) = ef7fabe3fea75d799d8628d155a8b72c
--- 10,12 ----
  MD5 (patch-ai) = 7d171eaaa0489cf4f24fd89fe45fda9e
! MD5 (patch-aj) = 2f1e748154c00130ff26c1b29c2f0c5b
  MD5 (patch-ak) = ef7fabe3fea75d799d8628d155a8b72c
Index: patches/patch-aj
===================================================================
RCS file: /cvsroot/pkgsrc/editors/emacs/patches/patch-aj,v
retrieving revision 1.7
diff -c -1 -r1.7 patch-aj
*** patches/patch-aj	2000/06/24 17:03:38	1.7
--- patches/patch-aj	2000/09/08 11:19:12
***************
*** 1,5 ****
! $NetBSD: patch-aj,v 1.7 2000/06/24 17:03:38 minoura Exp $
  
  --- src/process.c.orig	Wed May 24 04:10:16 2000
! +++ src/process.c	Sun Jun 18 09:20:15 2000
  @@ -1,7 +1,18 @@
--- 1,5 ----
! $NetBSD$
  
  --- src/process.c.orig	Wed May 24 04:10:16 2000
! +++ src/process.c	Mon Sep  4 14:15:19 2000
  @@ -1,7 +1,18 @@
***************
*** 27,30 ****
     register int i;
! +
! +#ifndef HAVE_GETADDRINFO
     struct sockaddr_in address;
--- 27,34 ----
     register int i;
! +#ifdef HAVE_GETADDRINFO
! +  struct addrinfo hints, *res, *lres;
! +  int ret = 0;
! +  int xerrno = 0;
! +  char *portstring, portbuf [128];
! +#else /* HAVE_GETADDRINFO */
     struct sockaddr_in address;
***************
*** 39,46 ****
  +  int port;
- +#else /* HAVE_GETADDRINFO */
- +  struct addrinfo hints, *res, *lres;
- +  int ret;
- +  char *portstring, portbuf [128];
  +#endif /* HAVE_GETADDRINFO */
! +  int s, outch, inch;
     struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
--- 43,46 ----
  +  int port;
  +#endif /* HAVE_GETADDRINFO */
! +  int s = -1, outch, inch;
     struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
***************
*** 71,73 ****
     else
! @@ -1841,6 +1874,8 @@
   	error ("Unknown service \"%s\"", XSTRING (service)->data);
--- 71,73 ----
     else
! @@ -1841,6 +1874,7 @@
   	error ("Unknown service \"%s\"", XSTRING (service)->data);
***************
*** 76,78 ****
  +#endif /* HAVE_GETADDRINFO */
- +
   
--- 76,77 ----
***************
*** 80,82 ****
        Some kernels have a bug which causes retrying connect to fail
! @@ -1850,6 +1885,88 @@
   #endif
--- 79,81 ----
        Some kernels have a bug which causes retrying connect to fail
! @@ -1850,6 +1884,75 @@
   #endif
***************
*** 84,167 ****
   #ifndef TERM
! +#ifdef HAVE_GETADDRINFO		       /* We have a modern OS. -wsr */
! +  {
! +      immediate_quit = 1;
! +      QUIT;
! +      memset(&hints, 0, sizeof(hints));
! +      hints.ai_flags = AI_NUMERICHOST;
! +      hints.ai_family = AF_UNSPEC;
! +      hints.ai_socktype = SOCK_STREAM;
! +      hints.ai_protocol = 0;
! +      ret = getaddrinfo(XSTRING (host)->data, portstring, &hints, &res);
! +      if (!ret) {	 /* numeric */
! +	 freeaddrinfo(res);
! +	 hints.ai_flags = AI_CANONNAME;
! +      } else {	 /* non-numeric */
! +	 hints.ai_flags = 0;
! +      }
! +      ret = getaddrinfo(XSTRING (host)->data, portstring, &hints, &res);
! +      if (ret){
! +	 error("%s/%s %s", XSTRING (host)->data, portstring,
! +	       gai_strerror(ret));
! +      }
! +      immediate_quit = 0;
! +  }
  +
! +  lres = res;
! +  addrloop: /* address loop */
  +      s = socket(lres->ai_family, lres->ai_socktype, lres->ai_protocol);
! +      if (s < 0) 
! +	 report_file_error ("error creating socket", Fcons (name, Qnil));
  +
  +      /* Kernel bugs (on Ultrix at least) cause lossage (not just EINTR)
! +	when connect is interrupted.  So let's not let it get interrupted.
! +	Note we do not turn off polling, because polling is only used
! +	when not interrupt_input, and thus not normally used on the systems
! +	which have this bug.  On systems which use polling, there's no way
! +	to quit if polling is turned off.  */
  +      if (interrupt_input)
! +	 unrequest_sigio ();
! +
! +  loop:
  +
  +      immediate_quit = 1;
  +      QUIT;
  +
! +      if (connect(s, lres->ai_addr, lres->ai_addrlen) == -1
! +	 && errno != EISCONN)
! +	 {
! +	     int xerrno = errno;
! +
! +	     immediate_quit = 0;
! +
! +	     if (errno == EINTR)
! +		 goto loop;
! +	     if (errno == EADDRINUSE && retry < 20)
! +		 {
! +		     /* A delay here is needed on some FreeBSD systems,
! +			and it is harmless, since this retrying takes time anyway
! +			and should be infrequent.  */
! +		     Fsleep_for (make_number (1), Qnil);
! +		     retry++;
! +		     goto loop;
! +		 }
! +
! +	     close (s);
! +
! +	     if (interrupt_input)
! +		 request_sigio ();
! +
! +	    if (lres->ai_next) {
! +		lres = lres->ai_next;
! +		goto addrloop;
! +	    }
! +
! +
! +	     errno = xerrno;
! +	     report_file_error ("connection failed",
! +				Fcons (host, Fcons (name, Qnil)));
! +	 }
! +  /* address loop */
  +  freeaddrinfo(res);
  +#else /* HAVE_GETADDRINFO */
- +
     while (1)
--- 83,153 ----
   #ifndef TERM
! +#ifdef HAVE_GETADDRINFO               /* We have a modern OS. -wsr */
! +  immediate_quit = 1;
! +  QUIT;
! +  memset(&hints, 0, sizeof(hints));
! +  hints.ai_flags = 0;
! +  hints.ai_family = AF_UNSPEC;
! +  hints.ai_socktype = SOCK_STREAM;
! +  hints.ai_protocol = 0;
! +  ret = getaddrinfo(XSTRING (host)->data, portstring, &hints, &res);
! +  if (ret)
! +    error("%s/%s %s", XSTRING (host)->data, portstring, gai_strerror(ret));
! +  immediate_quit = 0;
  +
! +  for (lres = res; lres ; lres = lres->ai_next)
! +    {
  +      s = socket(lres->ai_family, lres->ai_socktype, lres->ai_protocol);
! +      if (s < 0)
! +	{
! +	  xerrno = errno;
! +	  continue;
! +	}
  +
  +      /* Kernel bugs (on Ultrix at least) cause lossage (not just EINTR)
! +	 when connect is interrupted.  So let's not let it get interrupted.
! +	 Note we do not turn off polling, because polling is only used
! +	 when not interrupt_input, and thus not normally used on the systems
! +	 which have this bug.  On systems which use polling, there's no way
! +	 to quit if polling is turned off.  */
  +      if (interrupt_input)
! +        unrequest_sigio ();
  +
+ +    loop:
  +      immediate_quit = 1;
  +      QUIT;
+ +
+ +      if (connect(s, lres->ai_addr, lres->ai_addrlen) == 0 ||
+ +	  errno == EISCONN)
+ +	break;
+ +
+ +      xerrno = errno;
+ +      immediate_quit = 0;
  +
! +      if (errno == EINTR)
! +	goto loop;
! +      if (errno == EADDRINUSE && retry < 20)
! +	{
! +	  /* A delay here is needed on some FreeBSD systems,
! +	     and it is harmless, since this retrying takes time anyway
! +	     and should be infrequent.  */
! +	  Fsleep_for (make_number (1), Qnil);
! +	  retry++;
! +	  goto loop;
! +	}
! +      
! +      close(s);
! +      s = -1;
! +    }
! +
  +  freeaddrinfo(res);
+ +  if (s < 0)
+ +    {
+ +      if (interrupt_input)
+ +        request_sigio ();
+ +      
+ +      errno = xerrno;
+ +      report_file_error ("connection failed",
+ +			 Fcons (host, Fcons (name, Qnil)));
+ +    }
  +#else /* HAVE_GETADDRINFO */
     while (1)
***************
*** 169,171 ****
   #ifdef TRY_AGAIN
! @@ -1940,6 +2057,7 @@
         report_file_error ("connection failed",
--- 155,157 ----
   #ifdef TRY_AGAIN
! @@ -1940,6 +2043,7 @@
         report_file_error ("connection failed",