summaryrefslogtreecommitdiff
path: root/deps/uv
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-02-16 14:52:03 -0800
committerisaacs <i@izs.me>2012-02-16 15:32:15 -0800
commit7a1a62ec6e168876493688cfa45097567a332267 (patch)
treed4e7b85ddcb06270633427d7f45c5bdcf2160665 /deps/uv
parent30e462e91937ced3847af3fe9c393ebd32294b68 (diff)
downloadnode-new-7a1a62ec6e168876493688cfa45097567a332267.tar.gz
Upgrade uv to 86ebe48660e
Diffstat (limited to 'deps/uv')
-rw-r--r--deps/uv/include/uv-private/uv-win.h2
-rw-r--r--deps/uv/src/unix/tty.c4
-rw-r--r--deps/uv/src/win/error.c8
-rw-r--r--deps/uv/src/win/fs.c83
-rw-r--r--deps/uv/test/test-fs.c2
5 files changed, 53 insertions, 46 deletions
diff --git a/deps/uv/include/uv-private/uv-win.h b/deps/uv/include/uv-private/uv-win.h
index ea770132dd..e620f8b084 100644
--- a/deps/uv/include/uv-private/uv-win.h
+++ b/deps/uv/include/uv-private/uv-win.h
@@ -388,7 +388,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
#define UV_FS_PRIVATE_FIELDS \
wchar_t* pathw; \
int flags; \
- int last_error; \
+ DWORD sys_errno_; \
struct _stati64 stat; \
void* arg0; \
union { \
diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c
index 18a892168f..c1429660eb 100644
--- a/deps/uv/src/unix/tty.c
+++ b/deps/uv/src/unix/tty.c
@@ -76,8 +76,8 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {
raw.c_cc[VMIN] = 1;
raw.c_cc[VTIME] = 0;
- /* Put terminal in raw mode after flushing */
- if (tcsetattr(fd, TCSAFLUSH, &raw)) {
+ /* Put terminal in raw mode after draining */
+ if (tcsetattr(fd, TCSADRAIN, &raw)) {
goto fatal;
}
diff --git a/deps/uv/src/win/error.c b/deps/uv/src/win/error.c
index dd0018daa6..1922f2039b 100644
--- a/deps/uv/src/win/error.c
+++ b/deps/uv/src/win/error.c
@@ -84,6 +84,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case WSAECONNREFUSED: return UV_ECONNREFUSED;
case ERROR_NETNAME_DELETED: return UV_ECONNRESET;
case WSAECONNRESET: return UV_ECONNRESET;
+ case ERROR_ALREADY_EXISTS: return UV_EEXIST;
+ case ERROR_FILE_EXISTS: return UV_EEXIST;
case WSAEFAULT: return UV_EFAULT;
case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;
@@ -93,6 +95,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE;
case WSAEMFILE: return UV_EMFILE;
case WSAEMSGSIZE: return UV_EMSGSIZE;
+ case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG;
case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH;
case WSAENETUNREACH: return UV_ENETUNREACH;
case WSAENOBUFS: return UV_ENOBUFS;
@@ -105,9 +108,12 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case ERROR_INVALID_PARAMETER: return UV_EINVAL;
case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET;
case ERROR_BROKEN_PIPE: return UV_EOF;
+ case ERROR_BAD_PIPE: return UV_EPIPE;
+ case ERROR_NO_DATA: return UV_EPIPE;
+ case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE;
case ERROR_PIPE_BUSY: return UV_EBUSY;
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
- case ERROR_ALREADY_EXISTS: return UV_EEXIST;
+ case WSAETIMEDOUT: return UV_ETIMEDOUT;
case WSAHOST_NOT_FOUND: return UV_ENOENT;
default: return UV_UNKNOWN;
}
diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c
index 12ad514c48..94da291930 100644
--- a/deps/uv/src/win/fs.c
+++ b/deps/uv/src/win/fs.c
@@ -38,7 +38,6 @@
#define UV_FS_FREE_ARG1 0x0004
#define UV_FS_FREE_PTR 0x0008
#define UV_FS_CLEANEDUP 0x0010
-#define UV_FS_LAST_ERROR_SET 0x0020
#define UTF8_TO_UTF16(s, t) \
@@ -88,33 +87,30 @@
uv_ref((loop));
#define SET_UV_LAST_ERROR_FROM_REQ(req) \
- if (req->flags & UV_FS_LAST_ERROR_SET) { \
- uv__set_sys_error(req->loop, req->last_error); \
- } else if (req->result == -1) { \
- uv__set_error(req->loop, (uv_err_code)req->errorno, req->last_error); \
- }
-
-#define SET_REQ_LAST_ERROR(req, error) \
- req->last_error = error; \
- req->flags |= UV_FS_LAST_ERROR_SET;
+ uv__set_error(req->loop, req->errorno, req->sys_errno_);
#define SET_REQ_RESULT(req, result_value) \
req->result = (result_value); \
if (req->result == -1) { \
- req->last_error = _doserrno; \
- req->errorno = uv_translate_sys_error(req->last_error); \
+ req->sys_errno_ = _doserrno; \
+ req->errorno = uv_translate_sys_error(req->sys_errno_); \
}
-#define SET_REQ_RESULT_WIN32_ERROR(req, sys_errno) \
+#define SET_REQ_WIN32_ERROR(req, sys_errno) \
+ req->result = -1; \
+ req->sys_errno_ = (sys_errno); \
+ req->errorno = uv_translate_sys_error(req->sys_errno_);
+
+#define SET_REQ_UV_ERROR(req, uv_errno, sys_errno) \
req->result = -1; \
- req->errorno = uv_translate_sys_error(sys_errno); \
- SET_REQ_LAST_ERROR(req, sys_errno);
+ req->sys_errno_ = (sys_errno); \
+ req->errorno = (uv_errno);
#define VERIFY_UV_FILE(file, req) \
if (file == -1) { \
req->result = -1; \
req->errorno = UV_EBADF; \
- req->last_error = ERROR_SUCCESS; \
+ req->sys_errno_ = ERROR_SUCCESS; \
return; \
}
@@ -137,7 +133,7 @@ static void uv_fs_req_init_async(uv_loop_t* loop, uv_fs_t* req,
req->path = path ? strdup(path) : NULL;
req->pathw = (wchar_t*)pathw;
req->errorno = 0;
- req->last_error = 0;
+ req->sys_errno_ = 0;
memset(&req->overlapped, 0, sizeof(req->overlapped));
}
@@ -266,7 +262,15 @@ void fs__open(uv_fs_t* req, const wchar_t* path, int flags, int mode) {
attributes,
NULL);
if (file == INVALID_HANDLE_VALUE) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ DWORD error = GetLastError();
+ if (error == ERROR_FILE_EXISTS && (flags & _O_CREAT) &&
+ !(flags & _O_EXCL)) {
+ /* Special case: when ERROR_FILE_EXISTS happens and O_CREAT was */
+ /* specified, it means the path referred to a directory. */
+ SET_REQ_UV_ERROR(req, UV_EISDIR, error);
+ } else {
+ SET_REQ_WIN32_ERROR(req, GetLastError());
+ }
return;
}
result = _open_osfhandle((intptr_t)file, flags);
@@ -300,7 +304,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
}
if (length > INT_MAX) {
- SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
+ SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
return;
}
@@ -319,7 +323,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) {
SET_REQ_RESULT(req, bytes);
} else {
- SET_REQ_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
}
}
@@ -340,7 +344,7 @@ void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
}
if (length > INT_MAX) {
- SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
+ SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
return;
}
@@ -359,7 +363,7 @@ void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
if (WriteFile(handle, buf, length, &bytes, overlapped_ptr)) {
SET_REQ_RESULT(req, bytes);
} else {
- SET_REQ_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
}
}
@@ -398,7 +402,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
if (!(GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY)) {
req->result = -1;
req->errorno = UV_ENOTDIR;
- req->last_error = ERROR_SUCCESS;
+ req->sys_errno_ = ERROR_SUCCESS;
return;
}
@@ -416,7 +420,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
free(path2);
if(dir == INVALID_HANDLE_VALUE) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
@@ -460,7 +464,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
/* Convert result to UTF8. */
size = uv_utf16_to_utf8(buf, buf_char_len, NULL, 0);
if (!size) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
@@ -474,7 +478,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
free(buf);
free(req->ptr);
req->ptr = NULL;
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
free(buf);
@@ -491,7 +495,6 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
static void fs__stat(uv_fs_t* req, const wchar_t* path) {
HANDLE handle;
- int result;
BY_HANDLE_FILE_INFORMATION info;
req->ptr = NULL;
@@ -504,12 +507,12 @@ static void fs__stat(uv_fs_t* req, const wchar_t* path) {
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (handle == INVALID_HANDLE_VALUE) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
if (!GetFileInformationByHandle(handle, &info)) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
CloseHandle(handle);
return;
}
@@ -565,7 +568,7 @@ void fs__fstat(uv_fs_t* req, uv_file file) {
void fs__rename(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
if (!MoveFileExW(path, new_path, MOVEFILE_REPLACE_EXISTING)) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
@@ -580,7 +583,7 @@ void fs__fsync(uv_fs_t* req, uv_file file) {
result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
if (result == -1) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
} else {
SET_REQ_RESULT(req, result);
}
@@ -711,7 +714,7 @@ void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) {
void fs__link(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
int result = CreateHardLinkW(new_path, path, NULL) ? 0 : -1;
if (result == -1) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
} else {
SET_REQ_RESULT(req, result);
}
@@ -726,13 +729,11 @@ void fs__symlink(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path,
path,
flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1;
if (result == -1) {
- SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
} else {
- req->result = -1;
- req->errorno = UV_ENOTSUP;
- req->last_error = ERROR_SUCCESS;
+ SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED);
return;
}
@@ -761,7 +762,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
if (INVALID_HANDLE_VALUE == symlink) {
result = -1;
- SET_REQ_LAST_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@@ -781,7 +782,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
if (!rv) {
result = -1;
- SET_REQ_LAST_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@@ -789,7 +790,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
if (reparse_data->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
result = -1;
/* something is seriously wrong */
- SET_REQ_LAST_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@@ -810,7 +811,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
0);
if (!utf8size) {
result = -1;
- SET_REQ_LAST_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
@@ -825,7 +826,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
utf8size);
if (!utf8size) {
result = -1;
- SET_REQ_LAST_ERROR(req, GetLastError());
+ SET_REQ_WIN32_ERROR(req, GetLastError());
goto done;
}
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 006968829d..af2ebbf5bc 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -45,7 +45,7 @@
# define close _close
#endif
-#define TOO_LONG_NAME_LENGTH 8192
+#define TOO_LONG_NAME_LENGTH 65536
typedef struct {
const char* path;