FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Upgrade libuv to 9f6024a · wave2future/node@a23d8ad · GitHub

Repository navigation

Commit a23d8ad

Browse files
committed
Upgrade libuv to 9f6024a
Fixes nodejs#1840
1 parent 26c08a3 commit a23d8ad

9 files changed

Lines changed: 75 additions & 40 deletions

File tree

‎deps/uv/include/uv-private/uv-win.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
300300
int req_pending; \
301301
uv_fs_event_cb cb; \
302302
wchar_t* filew; \
303+
wchar_t* short_filew; \
303304
int is_path_dir; \
304305
char* buffer;
305306

‎deps/uv/include/uv.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,11 @@ struct uv_fs_event_s {
10631063
};
10641064

10651065

1066-
/* Gets load avg */
1066+
/*
1067+
* Gets load avg
1068+
* See: http://en.wikipedia.org/wiki/Load_(computing)
1069+
* (Returns [0,0,0] for windows and cygwin)
1070+
*/
10671071
void uv_loadavg(double avg[3]);
10681072

10691073
/*
@@ -1087,7 +1091,7 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size);
10871091
/* Gets the executable path */
10881092
int uv_exepath(char* buffer, size_t* size);
10891093

1090-
/* Memory info */
1094+
/* Gets memory info in bytes */
10911095
double uv_get_free_memory(void);
10921096
double uv_get_total_memory(void);
10931097

‎deps/uv/src/unix/stream.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,11 @@ static void uv__read(uv_stream_t* stream) {
600600
} else {
601601
stream->read2_cb((uv_pipe_t*)stream, nread, buf, UV_UNKNOWN_HANDLE);
602602
}
603+
}
603604

604-
/* Return if we didn't fill the buffer, there is no more data to read. */
605-
if (nread < buflen) {
606-
return;
607-
}
605+
/* Return if we didn't fill the buffer, there is no more data to read. */
606+
if (nread < buflen) {
607+
return;
608608
}
609609
}
610610
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
105105
case WSAECONNABORTED: return UV_ECONNABORTED;
106106
case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED;
107107
case WSAECONNREFUSED: return UV_ECONNREFUSED;
108+
case ERROR_NETNAME_DELETED: return UV_ECONNRESET;
109+
case WSAECONNRESET: return UV_ECONNRESET;
108110
case WSAEFAULT: return UV_EFAULT;
109111
case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
110112
case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;

‎deps/uv/src/win/fs-event.c‎

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ static void uv_fs_event_init_handle(uv_loop_t* loop, uv_fs_event_t* handle,
4141
handle->buffer = NULL;
4242
handle->req_pending = 0;
4343
handle->filew = NULL;
44-
44+
handle->short_filew = NULL;
45+
4546
uv_req_init(loop, (uv_req_t*)&handle->req);
4647
handle->req.type = UV_FS_EVENT_REQ;
4748
handle->req.data = (void*)handle;
@@ -95,25 +96,29 @@ static int uv_split_path(const wchar_t* filename, wchar_t** dir,
9596
while (i > 0 && filename[--i] != '\\' && filename[i] != '/');
9697

9798
if (i == 0) {
98-
*dir = (wchar_t*)malloc((MAX_PATH + 1) * sizeof(wchar_t));
99-
if (!*dir) {
100-
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
101-
}
102-
103-
if (!GetCurrentDirectoryW(MAX_PATH, *dir)) {
104-
free(*dir);
105-
*dir = NULL;
106-
return -1;
99+
if (dir) {
100+
*dir = (wchar_t*)malloc((MAX_PATH + 1) * sizeof(wchar_t));
101+
if (!*dir) {
102+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
103+
}
104+
105+
if (!GetCurrentDirectoryW(MAX_PATH, *dir)) {
106+
free(*dir);
107+
*dir = NULL;
108+
return -1;
109+
}
107110
}
108111

109112
*file = wcsdup(filename);
110113
} else {
111-
*dir = (wchar_t*)malloc((i + 1) * sizeof(wchar_t));
112-
if (!*dir) {
113-
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
114+
if (dir) {
115+
*dir = (wchar_t*)malloc((i + 1) * sizeof(wchar_t));
116+
if (!*dir) {
117+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
118+
}
119+
wcsncpy(*dir, filename, i);
120+
(*dir)[i] = L'\0';
114121
}
115-
wcsncpy(*dir, filename, i);
116-
(*dir)[i] = L'\0';
117122

118123
*file = (wchar_t*)malloc((len - i) * sizeof(wchar_t));
119124
if (!*file) {
@@ -132,6 +137,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
132137
int name_size;
133138
DWORD attr, last_error;
134139
wchar_t* dir = NULL, *dir_to_watch, *filenamew;
140+
wchar_t short_path[MAX_PATH];
135141

136142
uv_fs_event_init_handle(loop, handle, filename, cb);
137143

@@ -165,11 +171,23 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
165171
* filename is a file. So we split filename into dir & file parts, and
166172
* watch the dir directory.
167173
*/
174+
175+
/* Convert to short path. */
176+
if (!GetShortPathNameW(filenamew, short_path, COUNTOF(short_path))) {
177+
last_error = GetLastError();
178+
goto error;
179+
}
180+
168181
if (uv_split_path(filenamew, &dir, &handle->filew) != 0) {
169182
last_error = GetLastError();
170183
goto error;
171184
}
172185

186+
if (uv_split_path(short_path, NULL, &handle->short_filew) != 0) {
187+
last_error = GetLastError();
188+
goto error;
189+
}
190+
173191
dir_to_watch = dir;
174192
}
175193

@@ -194,9 +212,9 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
194212
}
195213

196214
if (CreateIoCompletionPort(handle->dir_handle,
197-
loop->iocp,
198-
(ULONG_PTR)handle,
199-
0) == NULL) {
215+
loop->iocp,
216+
(ULONG_PTR)handle,
217+
0) == NULL) {
200218
last_error = GetLastError();
201219
goto error;
202220
}
@@ -242,6 +260,11 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
242260
handle->filew = NULL;
243261
}
244262

263+
if (handle->short_filew) {
264+
free(handle->short_filew);
265+
handle->short_filew = NULL;
266+
}
267+
245268
if (handle->dir_handle != INVALID_HANDLE_VALUE) {
246269
CloseHandle(handle->dir_handle);
247270
handle->dir_handle = INVALID_HANDLE_VALUE;
@@ -279,8 +302,11 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
279302
* Fire the event only if we were asked to watch a directory,
280303
* or if the filename filter matches.
281304
*/
282-
if (handle->is_path_dir || _wcsnicmp(handle->filew, file_info->FileName,
283-
file_info->FileNameLength / sizeof(wchar_t)) == 0) {
305+
if (handle->is_path_dir ||
306+
_wcsnicmp(handle->filew, file_info->FileName,
307+
file_info->FileNameLength / sizeof(wchar_t)) == 0 ||
308+
_wcsnicmp(handle->short_filew, file_info->FileName,
309+
file_info->FileNameLength / sizeof(wchar_t)) == 0) {
284310

285311
/* Convert the filename to utf8. */
286312
utf8size = uv_utf16_to_utf8(file_info->FileName,
@@ -370,6 +396,11 @@ void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
370396
handle->filew = NULL;
371397
}
372398

399+
if (handle->short_filew) {
400+
free(handle->short_filew);
401+
handle->short_filew = NULL;
402+
}
403+
373404
if (handle->filename) {
374405
free(handle->filename);
375406
handle->filename = NULL;

‎deps/uv/src/win/internal.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ void uv_process_timers(uv_loop_t* loop);
6464
#define UV_HANDLE_SYNC_BYPASS_IOCP 0x20000
6565
#define UV_HANDLE_ZERO_READ 0x40000
6666
#define UV_HANDLE_TTY_RAW 0x80000
67-
#define UV_HANDLE_USE_IPC_PROTOCOL 0x100000
68-
#define UV_HANDLE_EMULATE_IOCP 0x200000
67+
#define UV_HANDLE_EMULATE_IOCP 0x100000
6968

7069
void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle);
7170
void uv_process_endgames(uv_loop_t* loop);

‎deps/uv/src/win/pipe.c‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,10 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
7878
handle->ipc_pid = 0;
7979
handle->remaining_ipc_rawdata_bytes = 0;
8080
handle->pending_socket_info = NULL;
81+
handle->ipc = ipc;
8182

8283
uv_req_init(loop, (uv_req_t*) &handle->ipc_header_write_req);
8384

84-
if (ipc) {
85-
handle->flags |= UV_HANDLE_USE_IPC_PROTOCOL;
86-
}
87-
8885
loop->counters.pipe_init++;
8986

9087
return 0;
@@ -585,7 +582,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) {
585582
uv_pipe_t* pipe_client;
586583
uv_pipe_accept_t* req;
587584

588-
if (server->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
585+
if (server->ipc) {
589586
if (!server->pending_socket_info) {
590587
/* No valid pending sockets. */
591588
uv__set_sys_error(loop, WSAEWOULDBLOCK);
@@ -780,7 +777,7 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req,
780777
req->ipc_header = 0;
781778
memset(&req->overlapped, 0, sizeof(req->overlapped));
782779

783-
if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
780+
if (handle->ipc) {
784781
/* Use the IPC framing protocol. */
785782
if (send_handle) {
786783
tcp_send_handle = (uv_tcp_t*)send_handle;
@@ -892,7 +889,7 @@ int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
892889

893890
int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
894891
uv_buf_t bufs[], int bufcnt, uv_stream_t* send_handle, uv_write_cb cb) {
895-
if (!(handle->flags & UV_HANDLE_USE_IPC_PROTOCOL)) {
892+
if (!handle->ipc) {
896893
uv__set_artificial_error(loop, UV_EINVAL);
897894
return -1;
898895
}
@@ -983,7 +980,7 @@ void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
983980
break;
984981
}
985982

986-
if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
983+
if (handle->ipc) {
987984
/* Use the IPC framing protocol to read the incoming data. */
988985
if (handle->remaining_ipc_rawdata_bytes == 0) {
989986
/* We're reading a new frame. First, read the header. */
@@ -1048,7 +1045,7 @@ void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
10481045
&bytes,
10491046
NULL)) {
10501047
/* Successful read */
1051-
if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
1048+
if (handle->ipc) {
10521049
assert(handle->remaining_ipc_rawdata_bytes >= bytes);
10531050
handle->remaining_ipc_rawdata_bytes =
10541051
handle->remaining_ipc_rawdata_bytes - bytes;
@@ -1280,7 +1277,7 @@ void uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
12801277
HANDLE os_handle;
12811278

12821279
/* Special-case stdin with ipc. */
1283-
if (file == 0 && pipe->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
1280+
if (file == 0 && pipe->ipc) {
12841281
os_handle = (HANDLE)_get_osfhandle(file);
12851282

12861283
if (os_handle == INVALID_HANDLE_VALUE ||

‎deps/uv/src/win/process.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
906906

907907
/* Create stdio pipes. */
908908
if (options.stdin_stream) {
909-
if (options.stdin_stream->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
909+
if (options.stdin_stream->ipc) {
910910
err = uv_create_stdio_pipe_pair(
911911
loop,
912912
options.stdin_stream,
@@ -985,7 +985,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
985985
process->pid = info.dwProcessId;
986986

987987
if (options.stdin_stream &&
988-
options.stdin_stream->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
988+
options.stdin_stream->ipc) {
989989
options.stdin_stream->ipc_pid = info.dwProcessId;
990990
}
991991

‎deps/uv/test/test-ipc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ TEST_IMPL(ipc) {
191191

192192
r = uv_pipe_init(uv_default_loop(), &channel, 1);
193193
ASSERT(r == 0);
194+
ASSERT(channel.ipc);
194195

195196
memset(&options, 0, sizeof(uv_process_options_t));
196197

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL