summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/udp.c
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <saghul@gmail.com>2015-08-05 21:17:46 +0200
committerthefourtheye <thechargingvolcano@gmail.com>2015-09-02 03:16:47 -0400
commita1615949a591fc523048a09540a2d340ff1b3da8 (patch)
tree1cc576ea6104f1baf8f92c6a82f3ca2b45afaccd /deps/uv/src/unix/udp.c
parente3740e452402892c1ce03bbbb4807e34f31558ad (diff)
downloadnode-new-a1615949a591fc523048a09540a2d340ff1b3da8.tar.gz
deps: upgrade libuv to 1.7.3
PR-URL: https://github.com/nodejs/node/pull/2310 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/uv/src/unix/udp.c')
-rw-r--r--deps/uv/src/unix/udp.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c
index f85ab1473a..66ecc4e341 100644
--- a/deps/uv/src/unix/udp.c
+++ b/deps/uv/src/unix/udp.c
@@ -321,6 +321,10 @@ int uv__udp_bind(uv_udp_t* handle,
if (bind(fd, addr, addrlen)) {
err = -errno;
+ if (errno == EAFNOSUPPORT)
+ /* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a
+ * socket created with AF_INET to an AF_INET6 address or vice versa. */
+ err = -EINVAL;
goto out;
}
@@ -551,25 +555,51 @@ static int uv__udp_set_membership6(uv_udp_t* handle,
}
-int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
+int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
+ int domain;
+ int err;
+ int fd;
+
+ /* Use the lower 8 bits for the domain */
+ domain = flags & 0xFF;
+ if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
+ return -EINVAL;
+
+ if (flags & ~0xFF)
+ return -EINVAL;
+
+ if (domain != AF_UNSPEC) {
+ err = uv__socket(domain, SOCK_DGRAM, 0);
+ if (err < 0)
+ return err;
+ fd = err;
+ } else {
+ fd = -1;
+ }
+
uv__handle_init(loop, (uv_handle_t*)handle, UV_UDP);
handle->alloc_cb = NULL;
handle->recv_cb = NULL;
handle->send_queue_size = 0;
handle->send_queue_count = 0;
- uv__io_init(&handle->io_watcher, uv__udp_io, -1);
+ uv__io_init(&handle->io_watcher, uv__udp_io, fd);
QUEUE_INIT(&handle->write_queue);
QUEUE_INIT(&handle->write_completed_queue);
return 0;
}
+int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
+ return uv_udp_init_ex(loop, handle, AF_UNSPEC);
+}
+
+
int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
int err;
/* Check for already active socket. */
if (handle->io_watcher.fd != -1)
- return -EALREADY; /* FIXME(bnoordhuis) Should be -EBUSY. */
+ return -EBUSY;
err = uv__nonblock(sock, 1);
if (err)
@@ -638,6 +668,8 @@ static int uv__setsockopt_maybe_char(uv_udp_t* handle,
int val) {
#if defined(__sun) || defined(_AIX)
char arg = val;
+#elif defined(__OpenBSD__)
+ unsigned char arg = val;
#else
int arg = val;
#endif
@@ -672,13 +704,13 @@ int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
* so hardcode the size of these options on this platform,
* and use the general uv__setsockopt_maybe_char call on other platforms.
*/
-#if defined(__sun) || defined(_AIX)
+#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__)
return uv__setsockopt(handle,
IP_TTL,
IPV6_UNICAST_HOPS,
&ttl,
sizeof(ttl));
-#endif /* defined(__sun) || defined(_AIX) */
+#endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) */
return uv__setsockopt_maybe_char(handle,
IP_TTL,