summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/tcp.c
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-10-24 22:13:07 -0400
committercjihrig <cjihrig@gmail.com>2016-10-26 09:42:41 -0400
commit63243bcb330408d511b3945c53719425d8b7abb8 (patch)
treef24252040adcc8c1a1dda22965fec39ac8df72de /deps/uv/src/unix/tcp.c
parent2d472a36c1d5e565fe375185f273402f84bed528 (diff)
downloadandroid-node-v8-63243bcb330408d511b3945c53719425d8b7abb8.tar.gz
android-node-v8-63243bcb330408d511b3945c53719425d8b7abb8.tar.bz2
android-node-v8-63243bcb330408d511b3945c53719425d8b7abb8.zip
deps: upgrade libuv to 1.10.0
Fixes: https://github.com/nodejs/node/issues/4351 Fixes: https://github.com/nodejs/node/issues/6763 Refs: https://github.com/nodejs/node/pull/8280 PR-URL: https://github.com/nodejs/node/pull/9267 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/uv/src/unix/tcp.c')
-rw-r--r--deps/uv/src/unix/tcp.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/deps/uv/src/unix/tcp.c b/deps/uv/src/unix/tcp.c
index 793e4c7d60..c423dcb15f 100644
--- a/deps/uv/src/unix/tcp.c
+++ b/deps/uv/src/unix/tcp.c
@@ -115,6 +115,10 @@ int uv__tcp_bind(uv_tcp_t* tcp,
IPV6_V6ONLY,
&on,
sizeof on) == -1) {
+#if defined(__MVS__)
+ if (errno == EOPNOTSUPP)
+ return -EINVAL;
+#endif
return -errno;
}
}
@@ -130,6 +134,7 @@ int uv__tcp_bind(uv_tcp_t* tcp,
}
tcp->delayed_error = -errno;
+ tcp->flags |= UV_HANDLE_BOUND;
if (addr->sa_family == AF_INET6)
tcp->flags |= UV_HANDLE_IPV6;
@@ -158,11 +163,17 @@ int uv__tcp_connect(uv_connect_t* req,
handle->delayed_error = 0;
- do
+ do {
+ errno = 0;
r = connect(uv__stream_fd(handle), addr, addrlen);
- while (r == -1 && errno == EINTR);
+ } while (r == -1 && errno == EINTR);
- if (r == -1) {
+ /* We not only check the return value, but also check the errno != 0.
+ * Because in rare cases connect() will return -1 but the errno
+ * is 0 (for example, on Android 4.3, OnePlus phone A0001_12_150227)
+ * and actually the tcp three-way handshake is completed.
+ */
+ if (r == -1 && errno != 0) {
if (errno == EINPROGRESS)
; /* not an error */
else if (errno == ECONNREFUSED)
@@ -266,10 +277,32 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
if (err)
return err;
+#ifdef __MVS__
+ /* on zOS the listen call does not bind automatically
+ if the socket is unbound. Hence the manual binding to
+ an arbitrary port is required to be done manually
+ */
+
+ if (!(tcp->flags & UV_HANDLE_BOUND)) {
+ struct sockaddr_storage saddr;
+ socklen_t slen = sizeof(saddr);
+ memset(&saddr, 0, sizeof(saddr));
+
+ if (getsockname(tcp->io_watcher.fd, (struct sockaddr*) &saddr, &slen))
+ return -errno;
+
+ if (bind(tcp->io_watcher.fd, (struct sockaddr*) &saddr, slen))
+ return -errno;
+
+ tcp->flags |= UV_HANDLE_BOUND;
+ }
+#endif
+
if (listen(tcp->io_watcher.fd, backlog))
return -errno;
tcp->connection_cb = cb;
+ tcp->flags |= UV_HANDLE_BOUND;
/* Start listening for connections. */
tcp->io_watcher.cb = uv__server_io;