Browse Source

uv: upgrade to b88bc43

v0.7.4-release
Ben Noordhuis 13 years ago
parent
commit
986e612557
  1. 34
      deps/uv/include/uv.h
  2. 1
      deps/uv/src/unix/error.c
  3. 30
      deps/uv/src/unix/udp.c
  4. 1
      deps/uv/src/win/error.c
  5. 28
      deps/uv/src/win/tty.c
  6. 12
      deps/uv/src/win/udp.c
  7. 36
      deps/uv/test/test-fs.c
  8. 2
      deps/uv/test/test-list.h

34
deps/uv/include/uv.h

@ -115,7 +115,8 @@ typedef intptr_t ssize_t;
XX( 45, EAISOCKTYPE, "") \
XX( 46, ESHUTDOWN, "") \
XX( 47, EEXIST, "file already exists") \
XX( 48, ESRCH, "no such process")
XX( 48, ESRCH, "no such process") \
XX( 49, ENAMETOOLONG, "name too long")
#define UV_ERRNO_GEN(val, name, s) UV_##name = val,
@ -631,6 +632,20 @@ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
const char* multicast_addr, const char* interface_addr,
uv_membership membership);
/*
* Set IP multicast loop flag. Makes multicast packets loop back to
* local sockets.
*
* Arguments:
* handle UDP handle. Should have been initialized with
* `uv_udp_init`.
* on 1 for on, 0 for off
*
* Returns:
* 0 on success, -1 on error.
*/
UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on);
/*
* Set the multicast ttl
*
@ -642,7 +657,7 @@ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
* Returns:
* 0 on success, -1 on error.
*/
int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
/*
* Set broadcast on or off
@ -655,7 +670,20 @@ int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
* Returns:
* 0 on success, -1 on error.
*/
int uv_udp_set_broadcast(uv_udp_t* handle, int on);
UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on);
/*
* Set the time to live
*
* Arguments:
* handle UDP handle. Should have been initialized with
* `uv_udp_init`.
* ttl 1 through 255
*
* Returns:
* 0 on success, -1 on error.
*/
UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl);
/*
* Send data. If the socket has not previously been bound with `uv_udp_bind`

1
deps/uv/src/unix/error.c

@ -71,6 +71,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EFAULT: return UV_EFAULT;
case EMFILE: return UV_EMFILE;
case EMSGSIZE: return UV_EMSGSIZE;
case ENAMETOOLONG: return UV_ENAMETOOLONG;
case EINVAL: return UV_EINVAL;
case ECONNREFUSED: return UV_ECONNREFUSED;
case EADDRINUSE: return UV_EADDRINUSE;

30
deps/uv/src/unix/udp.c

@ -509,27 +509,25 @@ int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr,
return 0;
}
int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) {
if (setsockopt(handle->fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof ttl) == -1) {
uv__set_sys_error(handle->loop, errno);
return -1;
}
return 0;
}
int uv_udp_set_broadcast(uv_udp_t* handle, int on) {
if (setsockopt(handle->fd, SOL_SOCKET, SO_BROADCAST, &on, sizeof on) == -1) {
uv__set_sys_error(handle->loop, errno);
return -1;
#define X(name, level, option) \
int uv_udp_set_##name(uv_udp_t* handle, int flag) { \
if (setsockopt(handle->fd, level, option, &flag, sizeof(flag))) { \
uv__set_sys_error(handle->loop, errno); \
return -1; \
} \
return 0; \
}
return 0;
}
X(multicast_loop, IPPROTO_IP, IP_MULTICAST_LOOP)
X(multicast_ttl, IPPROTO_IP, IP_MULTICAST_TTL)
X(broadcast, SOL_SOCKET, SO_BROADCAST)
X(ttl, IPPROTO_IP, IP_TTL)
#undef X
int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
int* namelen) {
int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen) {
socklen_t socklen;
int saved_errno;
int rv = 0;

1
deps/uv/src/win/error.c

@ -94,6 +94,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case WSAEMSGSIZE: return UV_EMSGSIZE;
case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH;
case WSAENETUNREACH: return UV_ENETUNREACH;
case WSAENOBUFS: return UV_ENOBUFS;
case ERROR_OUTOFMEMORY: return UV_ENOMEM;
case ERROR_NOT_CONNECTED: return UV_ENOTCONN;
case WSAENOTCONN: return UV_ENOTCONN;

28
deps/uv/src/win/tty.c

@ -1069,13 +1069,26 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
bg_bright = 0;
} else if (arg == 1) {
/* Bright */
/* Foreground bright on */
fg_bright = 1;
} else if (arg == 2) {
/* Both bright off */
fg_bright = 0;
bg_bright = 0;
} else if (arg == 5) {
/* Background bright on */
bg_bright = 1;
} else if (arg == 21 || arg == 22) {
/* Bright off. */
/* Foreground bright off */
fg_bright = 0;
} else if (arg == 25) {
/* Background bright off */
bg_bright = 0;
} else if (arg >= 30 && arg <= 37) {
/* Set foreground color */
fg_color = arg - 30;
@ -1091,6 +1104,17 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
} else if (arg == 49) {
/* Default background color */
bg_color = 0;
} else if (arg >= 90 && arg <= 97) {
/* Set bold foreground color */
fg_bright = 1;
fg_color = arg - 90;
} else if (arg >= 100 && arg <= 107) {
/* Set bold background color */
bg_bright = 1;
bg_color = arg - 100;
}
}

12
deps/uv/src/win/udp.c

@ -579,6 +579,12 @@ void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle,
}
int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) {
uv__set_artificial_error(handle->loop, UV_ENOSYS);
return -1;
}
int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) {
if (setsockopt(handle->socket, IPPROTO_IP, IP_MULTICAST_TTL,
(const char*)&ttl, sizeof ttl) == -1) {
@ -599,3 +605,9 @@ int uv_udp_set_broadcast(uv_udp_t* handle, int on) {
return 0;
}
int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
uv__set_artificial_error(handle->loop, UV_ENOSYS);
return -1;
}

36
deps/uv/test/test-fs.c

@ -45,6 +45,7 @@
# define close _close
#endif
#define TOO_LONG_NAME_LENGTH 8192
typedef struct {
const char* path;
@ -416,6 +417,14 @@ static void open_noent_cb(uv_fs_t* req) {
uv_fs_req_cleanup(req);
}
static void open_nametoolong_cb(uv_fs_t* req) {
ASSERT(req->fs_type == UV_FS_OPEN);
ASSERT(req->errorno == UV_ENAMETOOLONG);
ASSERT(req->result == -1);
open_cb_count++;
uv_fs_req_cleanup(req);
}
TEST_IMPL(fs_file_noent) {
uv_fs_t req;
@ -441,6 +450,31 @@ TEST_IMPL(fs_file_noent) {
return 0;
}
TEST_IMPL(fs_file_nametoolong) {
uv_fs_t req;
int r;
loop = uv_default_loop();
char name[TOO_LONG_NAME_LENGTH + 1];
memset(name, 'a', TOO_LONG_NAME_LENGTH);
name[TOO_LONG_NAME_LENGTH] = 0;
r = uv_fs_open(loop, &req, name, O_RDONLY, 0, NULL);
ASSERT(r == -1);
ASSERT(req.result == -1);
ASSERT(uv_last_error(loop).code == UV_ENAMETOOLONG);
uv_fs_req_cleanup(&req);
r = uv_fs_open(loop, &req, name, O_RDONLY, 0, open_nametoolong_cb);
ASSERT(r == 0);
ASSERT(open_cb_count == 0);
uv_run(loop);
ASSERT(open_cb_count == 1);
return 0;
}
static void check_utime(const char* path, double atime, double mtime) {
struct stat* s;
@ -1543,4 +1577,4 @@ TEST_IMPL(fs_rename_to_existing_file) {
unlink("test_file2");
return 0;
}
}

2
deps/uv/test/test-list.h

@ -103,6 +103,7 @@ TEST_DECLARE (spawn_and_kill)
TEST_DECLARE (spawn_and_ping)
TEST_DECLARE (kill)
TEST_DECLARE (fs_file_noent)
TEST_DECLARE (fs_file_nametoolong)
TEST_DECLARE (fs_file_async)
TEST_DECLARE (fs_file_sync)
TEST_DECLARE (fs_async_dir)
@ -269,6 +270,7 @@ TASK_LIST_START
#endif
TEST_ENTRY (fs_file_noent)
TEST_ENTRY (fs_file_nametoolong)
TEST_ENTRY (fs_file_async)
TEST_ENTRY (fs_file_sync)
TEST_ENTRY (fs_async_dir)

Loading…
Cancel
Save