summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2010-11-04 15:56:50 -0400
committerChong Yidong <cyd@stupidchicken.com>2010-11-04 15:56:50 -0400
commit748bc08a3ed399490614da9dd30403db8946454c (patch)
tree077dc09d2dbfd28a953d8de12c56bad62f83f9bd /src
parentf73334fdaa3d5a770a0d23b2ae945a93a874da71 (diff)
parent35e6786b61eba00ac48abec70f47c33c83d9b1a7 (diff)
downloademacs-748bc08a3ed399490614da9dd30403db8946454c.tar.gz
Backport fix for Bug#5723 from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog15
-rw-r--r--src/process.c50
2 files changed, 51 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 39a331d0800..4260890d7f8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+2010-11-04 Chong Yidong <cyd@stupidchicken.com>
+
+ * process.c (Fmake_network_process): Don't apply Bug#5173 fix for
+ Windows.
+
+2010-11-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * process.c (Fmake_network_process): Don't call turn_on_atimers around
+ `connect' (Bug#5723).
+
+2010-11-04 Helmut Eller <eller.helmut@gmail.com>
+
+ * process.c (Fmake_network_process): Call `select' for interrupted
+ `connect' rather than creating new socket (Bug#5173).
+
2010-11-04 Kenichi Handa <handa@m17n.org>
* font.c (font_delete_unmatched): Check Vface_ignored_fonts.
diff --git a/src/process.c b/src/process.c
index 567300e2f64..df30adcf0be 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3656,23 +3656,9 @@ usage: (make-network-process &rest ARGS) */)
immediate_quit = 1;
QUIT;
- /* This turns off all alarm-based interrupts; the
- bind_polling_period call above doesn't always turn all the
- short-interval ones off, especially if interrupt_input is
- set.
-
- It'd be nice to be able to control the connect timeout
- though. Would non-blocking connect calls be portable?
-
- This used to be conditioned by HAVE_GETADDRINFO. Why? */
-
- turn_on_atimers (0);
-
ret = connect (s, lres->ai_addr, lres->ai_addrlen);
xerrno = errno;
- turn_on_atimers (1);
-
if (ret == 0 || xerrno == EISCONN)
{
/* The unwind-protect will be discarded afterwards.
@@ -3692,6 +3678,40 @@ usage: (make-network-process &rest ARGS) */)
#endif
#endif
+#ifndef WINDOWSNT
+ if (xerrno == EINTR)
+ {
+ /* Unlike most other syscalls connect() cannot be called
+ again. (That would return EALREADY.) The proper way to
+ wait for completion is select(). */
+ int sc, len;
+ SELECT_TYPE fdset;
+ retry_select:
+ FD_ZERO (&fdset);
+ FD_SET (s, &fdset);
+ QUIT;
+ sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0,
+ (EMACS_TIME *)0);
+ if (sc == -1)
+ {
+ if (errno == EINTR)
+ goto retry_select;
+ else
+ report_file_error ("select failed", Qnil);
+ }
+ eassert (sc > 0);
+
+ len = sizeof xerrno;
+ eassert (FD_ISSET (s, &fdset));
+ if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1)
+ report_file_error ("getsockopt failed", Qnil);
+ if (xerrno)
+ errno = xerrno, report_file_error ("error during connect", Qnil);
+ else
+ break;
+ }
+#endif /* !WINDOWSNT */
+
immediate_quit = 0;
/* Discard the unwind protect closing S. */
@@ -3699,8 +3719,10 @@ usage: (make-network-process &rest ARGS) */)
emacs_close (s);
s = -1;
+#ifdef WINDOWSNT
if (xerrno == EINTR)
goto retry_connect;
+#endif
}
if (s >= 0)