summaryrefslogtreecommitdiff
path: root/deps/uv
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2011-09-06 00:24:39 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2011-09-06 02:15:08 +0200
commit554dc63328deb35ccbde1aadc6d776200fbc317f (patch)
tree75197f7d2dc6f38d983917050d8abcd2af50c9c7 /deps/uv
parentde978991d8dc11843a4d11ab438f53aea18d2526 (diff)
downloadnodejs-554dc63328deb35ccbde1aadc6d776200fbc317f.tar.gz
nodejs-554dc63328deb35ccbde1aadc6d776200fbc317f.tar.bz2
nodejs-554dc63328deb35ccbde1aadc6d776200fbc317f.zip
uv: upgrade to 58ef43e
Diffstat (limited to 'deps/uv')
-rw-r--r--deps/uv/config-unix.mk2
-rw-r--r--deps/uv/include/uv.h1
-rw-r--r--deps/uv/src/unix/core.c24
-rw-r--r--deps/uv/src/unix/error.c7
-rw-r--r--deps/uv/src/unix/fs.c13
-rw-r--r--deps/uv/src/unix/internal.h27
-rw-r--r--deps/uv/src/unix/process.c1
-rw-r--r--deps/uv/src/uv-common.c1
-rw-r--r--deps/uv/src/uv-common.h6
-rw-r--r--deps/uv/src/win/fs.c69
-rw-r--r--deps/uv/test/test-fs.c35
-rw-r--r--deps/uv/test/test-list.h2
12 files changed, 141 insertions, 47 deletions
diff --git a/deps/uv/config-unix.mk b/deps/uv/config-unix.mk
index e77ad2fee..7aa3a1654 100644
--- a/deps/uv/config-unix.mk
+++ b/deps/uv/config-unix.mk
@@ -58,7 +58,7 @@ endif
ifeq (Linux,$(uname_S))
EV_CONFIG=config_linux.h
EIO_CONFIG=config_linux.h
-CSTDFLAG += -D_XOPEN_SOURCE=600
+CSTDFLAG += -D_GNU_SOURCE
CPPFLAGS += -Isrc/ares/config_linux
LINKFLAGS+=-lrt
OBJS += src/unix/linux.o
diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
index bceb432d7..5b1144ef2 100644
--- a/deps/uv/include/uv.h
+++ b/deps/uv/include/uv.h
@@ -172,6 +172,7 @@ typedef enum {
UV_ENOTCONN,
UV_ENOTSOCK,
UV_ENOTSUP,
+ UV_ENOENT,
UV_EPIPE,
UV_EPROTO,
UV_EPROTONOSUPPORT,
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index a016d1b36..4d713c295 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -18,10 +18,6 @@
* IN THE SOFTWARE.
*/
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE /* O_CLOEXEC, accept4(), etc. */
-#endif
-
#include "uv.h"
#include "unix/internal.h"
@@ -42,26 +38,6 @@
#include <limits.h> /* PATH_MAX */
#include <sys/uio.h> /* writev */
-#if defined(__linux__)
-
-#include <linux/version.h>
-#include <features.h>
-
-#undef HAVE_PIPE2
-#undef HAVE_ACCEPT4
-
-/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
-#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
-#define HAVE_PIPE2
-#endif
-
-/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
-#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
-#define HAVE_ACCEPT4
-#endif
-
-#endif /* __linux__ */
-
#ifdef __sun
# include <sys/types.h>
# include <sys/wait.h>
diff --git a/deps/uv/src/unix/error.c b/deps/uv/src/unix/error.c
index b19aa577c..96615f36c 100644
--- a/deps/uv/src/unix/error.c
+++ b/deps/uv/src/unix/error.c
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
/* TODO Expose callback to user to handle fatal error like V8 does. */
@@ -65,9 +66,10 @@ char* uv_strerror(uv_err_t err) {
}
-static uv_err_code uv_translate_sys_error(int sys_errno) {
+uv_err_code uv_translate_sys_error(int sys_errno) {
switch (sys_errno) {
case 0: return UV_OK;
+ case ENOENT: return UV_ENOENT;
case EACCES: return UV_EACCESS;
case EBADF: return UV_EBADF;
case EPIPE: return UV_EPIPE;
@@ -83,6 +85,9 @@ static uv_err_code uv_translate_sys_error(int sys_errno) {
case ENOTCONN: return UV_ENOTCONN;
default: return UV_UNKNOWN;
}
+
+ assert(0 && "unreachable");
+ return -1;
}
diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c
index e0dc47d78..506367cde 100644
--- a/deps/uv/src/unix/fs.c
+++ b/deps/uv/src/unix/fs.c
@@ -32,6 +32,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <utime.h>
+#include <sys/time.h>
#define ARGS1(a) (a)
@@ -43,12 +44,12 @@
uv_fs_req_init(loop, req, type, path, cb); \
if (cb) { \
/* async */ \
- uv_ref(loop); \
req->eio = eiofunc(args, EIO_PRI_DEFAULT, uv__fs_after, req); \
if (!req->eio) { \
uv_err_new(loop, ENOMEM); \
return -1; \
} \
+ uv_ref(loop); \
} else { \
/* sync */ \
req->result = func(args); \
@@ -61,7 +62,7 @@
static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req, uv_fs_type fs_type,
- char* path, uv_fs_cb cb) {
+ const char* path, uv_fs_cb cb) {
/* Make sure the thread pool is initialized. */
uv_eio_init(loop);
@@ -110,7 +111,7 @@ static int uv__fs_after(eio_req* eio) {
assert(req->cb);
req->result = req->eio->result;
- req->errorno = req->eio->errorno;
+ req->errorno = uv_translate_sys_error(req->eio->errorno);
switch (req->fs_type) {
case UV_FS_READDIR:
@@ -344,7 +345,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
- char* pathdup = path;
+ char* pathdup;
int pathlen;
uv_fs_req_init(loop, req, UV_FS_STAT, path, cb);
@@ -479,7 +480,7 @@ int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
- char* pathdup = path;
+ char* pathdup;
int pathlen;
uv_fs_req_init(loop, req, UV_FS_LSTAT, path, cb);
@@ -538,7 +539,7 @@ int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb) {
- size_t size;
+ ssize_t size;
int status;
char* buf;
diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h
index 6e5be7da0..024a9b377 100644
--- a/deps/uv/src/unix/internal.h
+++ b/deps/uv/src/unix/internal.h
@@ -25,6 +25,32 @@
#include "uv-common.h"
#include "uv-eio.h"
+#if defined(__linux__)
+
+#include <linux/version.h>
+#include <features.h>
+
+#undef HAVE_FUTIMES
+#undef HAVE_PIPE2
+#undef HAVE_ACCEPT4
+
+/* futimes() requires linux >= 2.6.22 and glib >= 2.6 */
+#if LINUX_VERSION_CODE >= 0x20616 && __GLIBC_PREREQ(2, 6)
+#define HAVE_FUTIMES
+#endif
+
+/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
+#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
+#define HAVE_PIPE2
+#endif
+
+/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
+#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
+#define HAVE_ACCEPT4
+#endif
+
+#endif /* __linux__ */
+
/* flags */
enum {
UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */
@@ -48,6 +74,7 @@ int uv__cloexec(int fd, int set) __attribute__((unused));
int uv__socket(int domain, int type, int protocol);
/* error */
+uv_err_code uv_translate_sys_error(int sys_errno);
uv_err_t uv_err_new(uv_loop_t* loop, int sys_error);
uv_err_t uv_err_new_artificial(uv_loop_t* loop, int code);
void uv_fatal_error(const int errorno, const char* syscall);
diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c
index 349e0da6f..bbd24f450 100644
--- a/deps/uv/src/unix/process.c
+++ b/deps/uv/src/unix/process.c
@@ -26,6 +26,7 @@
#include <assert.h>
#include <errno.h>
#include <sys/wait.h>
+#include <fcntl.h> /* O_CLOEXEC, O_NONBLOCK */
#include <poll.h>
#include <unistd.h>
#include <stdio.h>
diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c
index 8e85db27a..ec31688fc 100644
--- a/deps/uv/src/uv-common.c
+++ b/deps/uv/src/uv-common.c
@@ -81,6 +81,7 @@ const char* uv_err_name(uv_err_t err) {
case UV_ENOTCONN: return "ENOTCONN";
case UV_ENOTSOCK: return "ENOTSOCK";
case UV_ENOTSUP: return "ENOTSUP";
+ case UV_ENOENT: return "ENOENT";
case UV_EPIPE: return "EPIPE";
case UV_EPROTO: return "EPROTO";
case UV_EPROTONOSUPPORT: return "EPROTONOSUPPORT";
diff --git a/deps/uv/src/uv-common.h b/deps/uv/src/uv-common.h
index 985412d79..212fc94ab 100644
--- a/deps/uv/src/uv-common.h
+++ b/deps/uv/src/uv-common.h
@@ -32,9 +32,9 @@
#define COUNTOF(a) (sizeof(a) / sizeof(a[0]))
/* Used for the uv_fs_ functions */
-#define SET_REQ_RESULT(req, result) \
- req->result = result; \
- if (result == -1) { \
+#define SET_REQ_RESULT(req, result_value) \
+ req->result = (result_value); \
+ if (req->result == -1) { \
req->errorno = errno; \
}
diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c
index 71ae451fa..885520c53 100644
--- a/deps/uv/src/win/fs.c
+++ b/deps/uv/src/win/fs.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <fcntl.h>
#include <io.h>
+#include <limits.h>
#include <sys/stat.h>
#include <sys/utime.h>
#include <stdio.h>
@@ -239,33 +240,77 @@ void fs__close(uv_fs_t* req, uv_file file) {
void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
off_t offset) {
- int result = 0;
+ HANDLE handle;
+ OVERLAPPED overlapped, *overlapped_ptr;
+ LARGE_INTEGER offset_;
+ DWORD bytes;
- if (offset != -1) {
- result = _lseek(file, offset, SEEK_SET);
+ handle = (HANDLE) _get_osfhandle(file);
+ if (handle == INVALID_HANDLE_VALUE) {
+ SET_REQ_RESULT(req, -1);
+ return;
}
- if (result != -1) {
- result = _read(file, buf, length);
+ if (length > INT_MAX) {
+ SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
+ return;
}
- SET_REQ_RESULT(req, result);
+ if (offset != -1) {
+ memset(&overlapped, 0, sizeof overlapped);
+
+ offset_.QuadPart = offset;
+ overlapped.Offset = offset_.LowPart;
+ overlapped.OffsetHigh = offset_.HighPart;
+
+ overlapped_ptr = &overlapped;
+ } else {
+ overlapped_ptr = NULL;
+ }
+
+ if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) {
+ SET_REQ_RESULT(req, bytes);
+ } else {
+ SET_REQ_ERROR(req, GetLastError());
+ }
}
void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
off_t offset) {
- int result = 0;
+ HANDLE handle;
+ OVERLAPPED overlapped, *overlapped_ptr;
+ LARGE_INTEGER offset_;
+ DWORD bytes;
- if (offset != -1) {
- result = _lseek(file, offset, SEEK_SET);
+ handle = (HANDLE) _get_osfhandle(file);
+ if (handle == INVALID_HANDLE_VALUE) {
+ SET_REQ_RESULT(req, -1);
+ return;
}
- if (result != -1) {
- result = _write(file, buf, length);
+ if (length > INT_MAX) {
+ SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
+ return;
}
- SET_REQ_RESULT(req, result);
+ if (offset != -1) {
+ memset(&overlapped, 0, sizeof overlapped);
+
+ offset_.QuadPart = offset;
+ overlapped.Offset = offset_.LowPart;
+ overlapped.OffsetHigh = offset_.HighPart;
+
+ overlapped_ptr = &overlapped;
+ } else {
+ overlapped_ptr = NULL;
+ }
+
+ if (WriteFile(handle, buf, length, &bytes, overlapped_ptr)) {
+ SET_REQ_RESULT(req, bytes);
+ } else {
+ SET_REQ_ERROR(req, GetLastError());
+ }
}
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index ef3b3b9e6..c3712def7 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -360,6 +360,41 @@ static void sendfile_cb(uv_fs_t* req) {
}
+static void open_noent_cb(uv_fs_t* req) {
+ ASSERT(req->fs_type == UV_FS_OPEN);
+ ASSERT(req->errorno == UV_ENOENT);
+ ASSERT(req->result == -1);
+ open_cb_count++;
+ uv_fs_req_cleanup(req);
+}
+
+
+TEST_IMPL(fs_file_noent) {
+ uv_fs_t req;
+ int r;
+
+ uv_init();
+ loop = uv_default_loop();
+
+ r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, NULL);
+ ASSERT(r == -1);
+ ASSERT(req.result == -1);
+ ASSERT(uv_last_error(loop).code == UV_ENOENT);
+ uv_fs_req_cleanup(&req);
+
+ r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, open_noent_cb);
+ ASSERT(r == 0);
+
+ ASSERT(open_cb_count == 0);
+ uv_run(loop);
+ ASSERT(open_cb_count == 1);
+
+ /* TODO add EACCES test */
+
+ return 0;
+}
+
+
TEST_IMPL(fs_file_async) {
int r;
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index fe8f1ed0b..9d4a57f69 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -72,6 +72,7 @@ TEST_DECLARE (spawn_exit_code)
TEST_DECLARE (spawn_stdout)
TEST_DECLARE (spawn_stdin)
TEST_DECLARE (spawn_and_kill)
+TEST_DECLARE (fs_file_noent)
TEST_DECLARE (fs_file_async)
TEST_DECLARE (fs_file_sync)
TEST_DECLARE (fs_async_dir)
@@ -180,6 +181,7 @@ TASK_LIST_START
TEST_ENTRY (environment_creation)
#endif
+ TEST_ENTRY (fs_file_noent)
TEST_ENTRY (fs_file_async)
TEST_ENTRY (fs_file_sync)
TEST_ENTRY (fs_async_dir)