aboutsummaryrefslogtreecommitdiffstats
path: root/editors/emacs20
diff options
context:
space:
mode:
authorsumikawa <sumikawa@FreeBSD.org>2000-09-04 15:22:16 +0800
committersumikawa <sumikawa@FreeBSD.org>2000-09-04 15:22:16 +0800
commitac20e26718cfa65417b601ce617dee52efac50cb (patch)
tree701219d0ee5b6827d8a018851b71c7c3eac68cb7 /editors/emacs20
parent68f9b03db533278d78328e289a2deff7c0706699 (diff)
downloadfreebsd-ports-graphics-ac20e26718cfa65417b601ce617dee52efac50cb.tar.gz
freebsd-ports-graphics-ac20e26718cfa65417b601ce617dee52efac50cb.tar.zst
freebsd-ports-graphics-ac20e26718cfa65417b601ce617dee52efac50cb.zip
Incorrect error code fix when a connection is failed.
Submitted by: kazu@iijlab.net Approved by: jseger
Diffstat (limited to 'editors/emacs20')
-rw-r--r--editors/emacs20/files/patch-cg111
1 files changed, 61 insertions, 50 deletions
diff --git a/editors/emacs20/files/patch-cg b/editors/emacs20/files/patch-cg
index b1087db71b9..ad2a7085089 100644
--- a/editors/emacs20/files/patch-cg
+++ b/editors/emacs20/files/patch-cg
@@ -1,5 +1,5 @@
--- src/process.c.orig Wed May 24 04:10:16 2000
-+++ src/process.c Sat Jul 1 20:37:08 2000
++++ src/process.c Mon Sep 4 14:15:19 2000
@@ -1,7 +1,18 @@
+/*
+ * Locally hacked process.c to add ipv6 support. -wsr
@@ -19,12 +19,16 @@
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
-@@ -1810,15 +1821,22 @@
+@@ -1810,15 +1821,21 @@
{
Lisp_Object proc;
register int i;
-+
-+#ifndef HAVE_GETADDRINFO
++#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;
struct servent *svc_info;
struct hostent *host_info_ptr, host_info;
@@ -35,17 +39,12 @@
- int port;
struct hostent host_info_fixed;
+ int port;
-+#else /* HAVE_GETADDRINFO */
-+ struct addrinfo hints, *res, *lres;
-+ int ret = 0;
-+ int xerrno = 0;
-+ char *portstring, portbuf [128];
+#endif /* HAVE_GETADDRINFO */
+ int s = -1, outch, inch;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int retry = 0;
int count = specpdl_ptr - specpdl;
-@@ -1831,6 +1849,22 @@
+@@ -1831,6 +1848,22 @@
GCPRO4 (name, buffer, host, service);
CHECK_STRING (name, 0);
CHECK_STRING (host, 0);
@@ -68,79 +67,91 @@
if (INTEGERP (service))
port = htons ((unsigned short) XINT (service));
else
-@@ -1841,6 +1875,8 @@
+@@ -1841,6 +1874,7 @@
error ("Unknown service \"%s\"", XSTRING (service)->data);
port = svc_info->s_port;
}
+#endif /* HAVE_GETADDRINFO */
-+
/* Slow down polling to every ten seconds.
Some kernels have a bug which causes retrying connect to fail
-@@ -1850,6 +1886,62 @@
+@@ -1850,6 +1884,75 @@
#endif
#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;
-+ }
++ 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) { /* address loop */
++ for (lres = res; lres ; lres = lres->ai_next)
++ {
+ s = socket(lres->ai_family, lres->ai_socktype, lres->ai_protocol);
-+ if (s < 0)
-+ continue;
++ 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. */
++ 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;
+
-+ ret = connect(s, lres->ai_addr, lres->ai_addrlen);
-+ if (ret){
-+ close(s);
-+ s= -1;
-+ continue;
-+ }
++ if (connect(s, lres->ai_addr, lres->ai_addrlen) == 0 ||
++ errno == EISCONN)
++ break;
+
-+ break;
-+ } /* address loop */
++ 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)));
-+ }
++ Fcons (host, Fcons (name, Qnil)));
++ }
+#else /* HAVE_GETADDRINFO */
-+
while (1)
{
#ifdef TRY_AGAIN
-@@ -1940,6 +2032,7 @@
+@@ -1940,6 +2043,7 @@
report_file_error ("connection failed",
Fcons (host, Fcons (name, Qnil)));
}