Skip to content
This repository
Browse code

Upgrade uv to 86ebe48660e

  • Loading branch information...
commit 7a1a62ec6e168876493688cfa45097567a332267 1 parent 30e462e
Isaac Z. Schlueter isaacs authored
2  deps/uv/include/uv-private/uv-win.h
@@ -388,7 +388,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
388 388 #define UV_FS_PRIVATE_FIELDS \
389 389 wchar_t* pathw; \
390 390 int flags; \
391   - int last_error; \
  391 + DWORD sys_errno_; \
392 392 struct _stati64 stat; \
393 393 void* arg0; \
394 394 union { \
4 deps/uv/src/unix/tty.c
@@ -76,8 +76,8 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {
76 76 raw.c_cc[VMIN] = 1;
77 77 raw.c_cc[VTIME] = 0;
78 78
79   - /* Put terminal in raw mode after flushing */
80   - if (tcsetattr(fd, TCSAFLUSH, &raw)) {
  79 + /* Put terminal in raw mode after draining */
  80 + if (tcsetattr(fd, TCSADRAIN, &raw)) {
81 81 goto fatal;
82 82 }
83 83
8 deps/uv/src/win/error.c
@@ -84,6 +84,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
84 84 case WSAECONNREFUSED: return UV_ECONNREFUSED;
85 85 case ERROR_NETNAME_DELETED: return UV_ECONNRESET;
86 86 case WSAECONNRESET: return UV_ECONNRESET;
  87 + case ERROR_ALREADY_EXISTS: return UV_EEXIST;
  88 + case ERROR_FILE_EXISTS: return UV_EEXIST;
87 89 case WSAEFAULT: return UV_EFAULT;
88 90 case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
89 91 case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;
@@ -93,6 +95,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
93 95 case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE;
94 96 case WSAEMFILE: return UV_EMFILE;
95 97 case WSAEMSGSIZE: return UV_EMSGSIZE;
  98 + case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG;
96 99 case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH;
97 100 case WSAENETUNREACH: return UV_ENETUNREACH;
98 101 case WSAENOBUFS: return UV_ENOBUFS;
@@ -105,9 +108,12 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
105 108 case ERROR_INVALID_PARAMETER: return UV_EINVAL;
106 109 case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET;
107 110 case ERROR_BROKEN_PIPE: return UV_EOF;
  111 + case ERROR_BAD_PIPE: return UV_EPIPE;
  112 + case ERROR_NO_DATA: return UV_EPIPE;
  113 + case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE;
108 114 case ERROR_PIPE_BUSY: return UV_EBUSY;
109 115 case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
110   - case ERROR_ALREADY_EXISTS: return UV_EEXIST;
  116 + case WSAETIMEDOUT: return UV_ETIMEDOUT;
111 117 case WSAHOST_NOT_FOUND: return UV_ENOENT;
112 118 default: return UV_UNKNOWN;
113 119 }
83 deps/uv/src/win/fs.c
@@ -38,7 +38,6 @@
38 38 #define UV_FS_FREE_ARG1 0x0004
39 39 #define UV_FS_FREE_PTR 0x0008
40 40 #define UV_FS_CLEANEDUP 0x0010
41   -#define UV_FS_LAST_ERROR_SET 0x0020
42 41
43 42
44 43 #define UTF8_TO_UTF16(s, t) \
@@ -88,33 +87,30 @@
88 87 uv_ref((loop));
89 88
90 89 #define SET_UV_LAST_ERROR_FROM_REQ(req) \
91   - if (req->flags & UV_FS_LAST_ERROR_SET) { \
92   - uv__set_sys_error(req->loop, req->last_error); \
93   - } else if (req->result == -1) { \
94   - uv__set_error(req->loop, (uv_err_code)req->errorno, req->last_error); \
95   - }
96   -
97   -#define SET_REQ_LAST_ERROR(req, error) \
98   - req->last_error = error; \
99   - req->flags |= UV_FS_LAST_ERROR_SET;
  90 + uv__set_error(req->loop, req->errorno, req->sys_errno_);
100 91
101 92 #define SET_REQ_RESULT(req, result_value) \
102 93 req->result = (result_value); \
103 94 if (req->result == -1) { \
104   - req->last_error = _doserrno; \
105   - req->errorno = uv_translate_sys_error(req->last_error); \
  95 + req->sys_errno_ = _doserrno; \
  96 + req->errorno = uv_translate_sys_error(req->sys_errno_); \
106 97 }
107 98
108   -#define SET_REQ_RESULT_WIN32_ERROR(req, sys_errno) \
  99 +#define SET_REQ_WIN32_ERROR(req, sys_errno) \
  100 + req->result = -1; \
  101 + req->sys_errno_ = (sys_errno); \
  102 + req->errorno = uv_translate_sys_error(req->sys_errno_);
  103 +
  104 +#define SET_REQ_UV_ERROR(req, uv_errno, sys_errno) \
109 105 req->result = -1; \
110   - req->errorno = uv_translate_sys_error(sys_errno); \
111   - SET_REQ_LAST_ERROR(req, sys_errno);
  106 + req->sys_errno_ = (sys_errno); \
  107 + req->errorno = (uv_errno);
112 108
113 109 #define VERIFY_UV_FILE(file, req) \
114 110 if (file == -1) { \
115 111 req->result = -1; \
116 112 req->errorno = UV_EBADF; \
117   - req->last_error = ERROR_SUCCESS; \
  113 + req->sys_errno_ = ERROR_SUCCESS; \
118 114 return; \
119 115 }
120 116
@@ -137,7 +133,7 @@ static void uv_fs_req_init_async(uv_loop_t* loop, uv_fs_t* req,
137 133 req->path = path ? strdup(path) : NULL;
138 134 req->pathw = (wchar_t*)pathw;
139 135 req->errorno = 0;
140   - req->last_error = 0;
  136 + req->sys_errno_ = 0;
141 137 memset(&req->overlapped, 0, sizeof(req->overlapped));
142 138 }
143 139
@@ -266,7 +262,15 @@ void fs__open(uv_fs_t* req, const wchar_t* path, int flags, int mode) {
266 262 attributes,
267 263 NULL);
268 264 if (file == INVALID_HANDLE_VALUE) {
269   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  265 + DWORD error = GetLastError();
  266 + if (error == ERROR_FILE_EXISTS && (flags & _O_CREAT) &&
  267 + !(flags & _O_EXCL)) {
  268 + /* Special case: when ERROR_FILE_EXISTS happens and O_CREAT was */
  269 + /* specified, it means the path referred to a directory. */
  270 + SET_REQ_UV_ERROR(req, UV_EISDIR, error);
  271 + } else {
  272 + SET_REQ_WIN32_ERROR(req, GetLastError());
  273 + }
270 274 return;
271 275 }
272 276 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,
300 304 }
301 305
302 306 if (length > INT_MAX) {
303   - SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
  307 + SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
304 308 return;
305 309 }
306 310
@@ -319,7 +323,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
319 323 if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) {
320 324 SET_REQ_RESULT(req, bytes);
321 325 } else {
322   - SET_REQ_ERROR(req, GetLastError());
  326 + SET_REQ_WIN32_ERROR(req, GetLastError());
323 327 }
324 328 }
325 329
@@ -340,7 +344,7 @@ void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
340 344 }
341 345
342 346 if (length > INT_MAX) {
343   - SET_REQ_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
  347 + SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
344 348 return;
345 349 }
346 350
@@ -359,7 +363,7 @@ void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
359 363 if (WriteFile(handle, buf, length, &bytes, overlapped_ptr)) {
360 364 SET_REQ_RESULT(req, bytes);
361 365 } else {
362   - SET_REQ_ERROR(req, GetLastError());
  366 + SET_REQ_WIN32_ERROR(req, GetLastError());
363 367 }
364 368 }
365 369
@@ -398,7 +402,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
398 402 if (!(GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY)) {
399 403 req->result = -1;
400 404 req->errorno = UV_ENOTDIR;
401   - req->last_error = ERROR_SUCCESS;
  405 + req->sys_errno_ = ERROR_SUCCESS;
402 406 return;
403 407 }
404 408
@@ -416,7 +420,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
416 420 free(path2);
417 421
418 422 if(dir == INVALID_HANDLE_VALUE) {
419   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  423 + SET_REQ_WIN32_ERROR(req, GetLastError());
420 424 return;
421 425 }
422 426
@@ -460,7 +464,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
460 464 /* Convert result to UTF8. */
461 465 size = uv_utf16_to_utf8(buf, buf_char_len, NULL, 0);
462 466 if (!size) {
463   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  467 + SET_REQ_WIN32_ERROR(req, GetLastError());
464 468 return;
465 469 }
466 470
@@ -474,7 +478,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
474 478 free(buf);
475 479 free(req->ptr);
476 480 req->ptr = NULL;
477   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  481 + SET_REQ_WIN32_ERROR(req, GetLastError());
478 482 return;
479 483 }
480 484 free(buf);
@@ -491,7 +495,6 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
491 495
492 496 static void fs__stat(uv_fs_t* req, const wchar_t* path) {
493 497 HANDLE handle;
494   - int result;
495 498 BY_HANDLE_FILE_INFORMATION info;
496 499
497 500 req->ptr = NULL;
@@ -504,12 +507,12 @@ static void fs__stat(uv_fs_t* req, const wchar_t* path) {
504 507 FILE_FLAG_BACKUP_SEMANTICS,
505 508 NULL);
506 509 if (handle == INVALID_HANDLE_VALUE) {
507   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  510 + SET_REQ_WIN32_ERROR(req, GetLastError());
508 511 return;
509 512 }
510 513
511 514 if (!GetFileInformationByHandle(handle, &info)) {
512   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  515 + SET_REQ_WIN32_ERROR(req, GetLastError());
513 516 CloseHandle(handle);
514 517 return;
515 518 }
@@ -565,7 +568,7 @@ void fs__fstat(uv_fs_t* req, uv_file file) {
565 568
566 569 void fs__rename(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
567 570 if (!MoveFileExW(path, new_path, MOVEFILE_REPLACE_EXISTING)) {
568   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  571 + SET_REQ_WIN32_ERROR(req, GetLastError());
569 572 return;
570 573 }
571 574
@@ -580,7 +583,7 @@ void fs__fsync(uv_fs_t* req, uv_file file) {
580 583
581 584 result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
582 585 if (result == -1) {
583   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  586 + SET_REQ_WIN32_ERROR(req, GetLastError());
584 587 } else {
585 588 SET_REQ_RESULT(req, result);
586 589 }
@@ -711,7 +714,7 @@ void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) {
711 714 void fs__link(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
712 715 int result = CreateHardLinkW(new_path, path, NULL) ? 0 : -1;
713 716 if (result == -1) {
714   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  717 + SET_REQ_WIN32_ERROR(req, GetLastError());
715 718 } else {
716 719 SET_REQ_RESULT(req, result);
717 720 }
@@ -726,13 +729,11 @@ void fs__symlink(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path,
726 729 path,
727 730 flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1;
728 731 if (result == -1) {
729   - SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  732 + SET_REQ_WIN32_ERROR(req, GetLastError());
730 733 return;
731 734 }
732 735 } else {
733   - req->result = -1;
734   - req->errorno = UV_ENOTSUP;
735   - req->last_error = ERROR_SUCCESS;
  736 + SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED);
736 737 return;
737 738 }
738 739
@@ -761,7 +762,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
761 762
762 763 if (INVALID_HANDLE_VALUE == symlink) {
763 764 result = -1;
764   - SET_REQ_LAST_ERROR(req, GetLastError());
  765 + SET_REQ_WIN32_ERROR(req, GetLastError());
765 766 goto done;
766 767 }
767 768
@@ -781,7 +782,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
781 782
782 783 if (!rv) {
783 784 result = -1;
784   - SET_REQ_LAST_ERROR(req, GetLastError());
  785 + SET_REQ_WIN32_ERROR(req, GetLastError());
785 786 goto done;
786 787 }
787 788
@@ -789,7 +790,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
789 790 if (reparse_data->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
790 791 result = -1;
791 792 /* something is seriously wrong */
792   - SET_REQ_LAST_ERROR(req, GetLastError());
  793 + SET_REQ_WIN32_ERROR(req, GetLastError());
793 794 goto done;
794 795 }
795 796
@@ -810,7 +811,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
810 811 0);
811 812 if (!utf8size) {
812 813 result = -1;
813   - SET_REQ_LAST_ERROR(req, GetLastError());
  814 + SET_REQ_WIN32_ERROR(req, GetLastError());
814 815 goto done;
815 816 }
816 817
@@ -825,7 +826,7 @@ void fs__readlink(uv_fs_t* req, const wchar_t* path) {
825 826 utf8size);
826 827 if (!utf8size) {
827 828 result = -1;
828   - SET_REQ_LAST_ERROR(req, GetLastError());
  829 + SET_REQ_WIN32_ERROR(req, GetLastError());
829 830 goto done;
830 831 }
831 832
2  deps/uv/test/test-fs.c
@@ -45,7 +45,7 @@
45 45 # define close _close
46 46 #endif
47 47
48   -#define TOO_LONG_NAME_LENGTH 8192
  48 +#define TOO_LONG_NAME_LENGTH 65536
49 49
50 50 typedef struct {
51 51 const char* path;

0 comments on commit 7a1a62e

Please sign in to comment.
Something went wrong with that request. Please try again.