aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1999-08-14 04:36:10 +0000
committerKarl Heuer1999-08-14 04:36:10 +0000
commit418b48fddf54a24220d4d9ab31a28e709473d1c7 (patch)
tree782bab35c6d71ae66eb9c7f17af4783f0500509b /src
parentc5fee54517a65d1aa07253dd8f434e0d9cfc9c03 (diff)
downloademacs-418b48fddf54a24220d4d9ab31a28e709473d1c7.tar.gz
emacs-418b48fddf54a24220d4d9ab31a28e709473d1c7.zip
(Fopen_network_stream): Fix previous change.
Diffstat (limited to 'src')
-rw-r--r--src/process.c58
1 files changed, 14 insertions, 44 deletions
diff --git a/src/process.c b/src/process.c
index 4d2cc5e10ac..b4eaa9ca28f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1824,13 +1824,13 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\
1824 IN_ADDR numeric_addr; 1824 IN_ADDR numeric_addr;
1825 struct hostent host_info_fixed; 1825 struct hostent host_info_fixed;
1826 int port; 1826 int port;
1827#else /* ! HAVE_GETADDRINFO */ 1827#else /* HAVE_GETADDRINFO */
1828 struct addrinfo hints, *res, *lres; 1828 struct addrinfo hints, *res, *lres;
1829 int ret = 0; 1829 int ret = 0;
1830 int xerrno = 0; 1830 int xerrno = 0;
1831 char *portstring, portbuf [128]; 1831 char *portstring, portbuf[128];
1832#endif /* ! HAVE_GETADDRINFO */ 1832#endif /* HAVE_GETADDRINFO */
1833 int s, outch, inch; 1833 int s = -1, outch, inch;
1834 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1834 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1835 int retry = 0; 1835 int retry = 0;
1836 int count = specpdl_ptr - specpdl; 1836 int count = specpdl_ptr - specpdl;
@@ -1886,34 +1886,24 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\
1886 immediate_quit = 1; 1886 immediate_quit = 1;
1887 QUIT; 1887 QUIT;
1888 memset (&hints, 0, sizeof (hints)); 1888 memset (&hints, 0, sizeof (hints));
1889 hints.ai_flags = AI_NUMERICHOST; 1889 hints.ai_flags = 0;
1890 hints.ai_family = AF_UNSPEC; 1890 hints.ai_family = AF_UNSPEC;
1891 hints.ai_socktype = SOCK_STREAM; 1891 hints.ai_socktype = SOCK_STREAM;
1892 hints.ai_protocol = 0; 1892 hints.ai_protocol = 0;
1893 ret = getaddrinfo (XSTRING (host)->data, portstring, &hints, &res); 1893 ret = getaddrinfo (XSTRING (host)->data, portstring, &hints, &res);
1894 if (!ret) /* numeric */
1895 {
1896 freeaddrinfo (res);
1897 hints.ai_flags = AI_CANONNAME;
1898 }
1899 else /* non-numeric */
1900 {
1901 hints.ai_flags = 0;
1902 }
1903 ret = getaddrinfo (XSTRING (host)->data, portstring, &hints, &res);
1904 if (ret) 1894 if (ret)
1905 { 1895 {
1906 error ("%s/%s %s", XSTRING (host)->data, portstring, 1896 error ("%s/%s %s", XSTRING (host)->data, portstring,
1907 gai_strerror (ret)); 1897 gai_strerror (ret));
1908 } 1898 }
1909 immediate_quit = 0; 1899 immediate_quit = 0;
1910 } 1900 }
1911 1901
1912 for (lres = res; lres ; lres = lres->ai_next) 1902 for (lres = res; lres; lres = lres->ai_next)
1913 { 1903 {
1914 s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); 1904 s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol);
1915 if (s < 0) 1905 if (s < 0)
1916 report_file_error ("error creating socket", Fcons (name, Qnil)); 1906 continue;
1917 1907
1918 /* Kernel bugs (on Ultrix at least) cause lossage (not just EINTR) 1908 /* Kernel bugs (on Ultrix at least) cause lossage (not just EINTR)
1919 when connect is interrupted. So let's not let it get interrupted. 1909 when connect is interrupted. So let's not let it get interrupted.
@@ -1924,38 +1914,18 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\
1924 if (interrupt_input) 1914 if (interrupt_input)
1925 unrequest_sigio (); 1915 unrequest_sigio ();
1926 1916
1927 loop:
1928
1929 immediate_quit = 1; 1917 immediate_quit = 1;
1930 QUIT; 1918 QUIT;
1931 1919
1932 ret = connect (s, lres->ai_addr, lres->ai_addrlen); 1920 ret = connect (s, lres->ai_addr, lres->ai_addrlen);
1933 1921 if (ret == 0)
1934 if (ret == -1 && errno != EISCONN)
1935 {
1936 xerrno = errno;
1937
1938 immediate_quit = 0;
1939
1940 if (errno == EINTR)
1941 goto loop;
1942 if (errno == EADDRINUSE && retry < 20)
1943 {
1944 /* A delay here is needed on some FreeBSD systems,
1945 and it is harmless, since this retrying takes time anyway
1946 and should be infrequent. */
1947 Fsleep_for (make_number (1), Qnil);
1948 retry++;
1949 goto loop;
1950 }
1951
1952 close (s);
1953 }
1954 if (ret == 0) /* We got a valid connect */
1955 break; 1922 break;
1956 } /* address loop */ 1923 close (s);
1924 s = -1;
1925 }
1926
1957 freeaddrinfo (res); 1927 freeaddrinfo (res);
1958 if (ret != 0) 1928 if (s < 0)
1959 { 1929 {
1960 if (interrupt_input) 1930 if (interrupt_input)
1961 request_sigio (); 1931 request_sigio ();