diff options
author | sumikawa <sumikawa@FreeBSD.org> | 2000-09-04 15:56:17 +0800 |
---|---|---|
committer | sumikawa <sumikawa@FreeBSD.org> | 2000-09-04 15:56:17 +0800 |
commit | a4611b0dd92f7697bbb168180fc76a491ff48baf (patch) | |
tree | a1c51dfba231b4779e02ca3db7459828509dce63 /editors/emacs20-dl/files | |
parent | ac20e26718cfa65417b601ce617dee52efac50cb (diff) | |
download | freebsd-ports-gnome-a4611b0dd92f7697bbb168180fc76a491ff48baf.tar.gz freebsd-ports-gnome-a4611b0dd92f7697bbb168180fc76a491ff48baf.tar.zst freebsd-ports-gnome-a4611b0dd92f7697bbb168180fc76a491ff48baf.zip |
Incorrect error code fix when a connection is failed.
Submitted by: kazu@iijlab.net
Approved by: shige
Diffstat (limited to 'editors/emacs20-dl/files')
-rw-r--r-- | editors/emacs20-dl/files/patch-cg | 111 |
1 files changed, 61 insertions, 50 deletions
diff --git a/editors/emacs20-dl/files/patch-cg b/editors/emacs20-dl/files/patch-cg index b1087db71b9e..ad2a70850899 100644 --- a/editors/emacs20-dl/files/patch-cg +++ b/editors/emacs20-dl/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))); } |