Browse Source

Upgrade libuv to 9f6024a

Fixes #1840
v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
a23d8ad313
  1. 1
      deps/uv/include/uv-private/uv-win.h
  2. 8
      deps/uv/include/uv.h
  3. 8
      deps/uv/src/unix/stream.c
  4. 2
      deps/uv/src/win/error.c
  5. 71
      deps/uv/src/win/fs-event.c
  6. 3
      deps/uv/src/win/internal.h
  7. 17
      deps/uv/src/win/pipe.c
  8. 4
      deps/uv/src/win/process.c
  9. 1
      deps/uv/test/test-ipc.c

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

@ -300,6 +300,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
int req_pending; \
uv_fs_event_cb cb; \
wchar_t* filew; \
wchar_t* short_filew; \
int is_path_dir; \
char* buffer;

8
deps/uv/include/uv.h

@ -1063,7 +1063,11 @@ struct uv_fs_event_s {
};
/* Gets load avg */
/*
* Gets load avg
* See: http://en.wikipedia.org/wiki/Load_(computing)
* (Returns [0,0,0] for windows and cygwin)
*/
void uv_loadavg(double avg[3]);
/*
@ -1087,7 +1091,7 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size);
/* Gets the executable path */
int uv_exepath(char* buffer, size_t* size);
/* Memory info */
/* Gets memory info in bytes */
double uv_get_free_memory(void);
double uv_get_total_memory(void);

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

@ -600,11 +600,11 @@ static void uv__read(uv_stream_t* stream) {
} else {
stream->read2_cb((uv_pipe_t*)stream, nread, buf, UV_UNKNOWN_HANDLE);
}
}
/* Return if we didn't fill the buffer, there is no more data to read. */
if (nread < buflen) {
return;
}
/* Return if we didn't fill the buffer, there is no more data to read. */
if (nread < buflen) {
return;
}
}
}

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

@ -105,6 +105,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case WSAECONNABORTED: return UV_ECONNABORTED;
case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED;
case WSAECONNREFUSED: return UV_ECONNREFUSED;
case ERROR_NETNAME_DELETED: return UV_ECONNRESET;
case WSAECONNRESET: return UV_ECONNRESET;
case WSAEFAULT: return UV_EFAULT;
case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;

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

@ -41,7 +41,8 @@ static void uv_fs_event_init_handle(uv_loop_t* loop, uv_fs_event_t* handle,
handle->buffer = NULL;
handle->req_pending = 0;
handle->filew = NULL;
handle->short_filew = NULL;
uv_req_init(loop, (uv_req_t*)&handle->req);
handle->req.type = UV_FS_EVENT_REQ;
handle->req.data = (void*)handle;
@ -95,25 +96,29 @@ static int uv_split_path(const wchar_t* filename, wchar_t** dir,
while (i > 0 && filename[--i] != '\\' && filename[i] != '/');
if (i == 0) {
*dir = (wchar_t*)malloc((MAX_PATH + 1) * sizeof(wchar_t));
if (!*dir) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
if (!GetCurrentDirectoryW(MAX_PATH, *dir)) {
free(*dir);
*dir = NULL;
return -1;
if (dir) {
*dir = (wchar_t*)malloc((MAX_PATH + 1) * sizeof(wchar_t));
if (!*dir) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
if (!GetCurrentDirectoryW(MAX_PATH, *dir)) {
free(*dir);
*dir = NULL;
return -1;
}
}
*file = wcsdup(filename);
} else {
*dir = (wchar_t*)malloc((i + 1) * sizeof(wchar_t));
if (!*dir) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
if (dir) {
*dir = (wchar_t*)malloc((i + 1) * sizeof(wchar_t));
if (!*dir) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
wcsncpy(*dir, filename, i);
(*dir)[i] = L'\0';
}
wcsncpy(*dir, filename, i);
(*dir)[i] = L'\0';
*file = (wchar_t*)malloc((len - i) * sizeof(wchar_t));
if (!*file) {
@ -132,6 +137,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
int name_size;
DWORD attr, last_error;
wchar_t* dir = NULL, *dir_to_watch, *filenamew;
wchar_t short_path[MAX_PATH];
uv_fs_event_init_handle(loop, handle, filename, cb);
@ -165,11 +171,23 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
* filename is a file. So we split filename into dir & file parts, and
* watch the dir directory.
*/
/* Convert to short path. */
if (!GetShortPathNameW(filenamew, short_path, COUNTOF(short_path))) {
last_error = GetLastError();
goto error;
}
if (uv_split_path(filenamew, &dir, &handle->filew) != 0) {
last_error = GetLastError();
goto error;
}
if (uv_split_path(short_path, NULL, &handle->short_filew) != 0) {
last_error = GetLastError();
goto error;
}
dir_to_watch = dir;
}
@ -194,9 +212,9 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
}
if (CreateIoCompletionPort(handle->dir_handle,
loop->iocp,
(ULONG_PTR)handle,
0) == NULL) {
loop->iocp,
(ULONG_PTR)handle,
0) == NULL) {
last_error = GetLastError();
goto error;
}
@ -242,6 +260,11 @@ error:
handle->filew = NULL;
}
if (handle->short_filew) {
free(handle->short_filew);
handle->short_filew = NULL;
}
if (handle->dir_handle != INVALID_HANDLE_VALUE) {
CloseHandle(handle->dir_handle);
handle->dir_handle = INVALID_HANDLE_VALUE;
@ -279,8 +302,11 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
* Fire the event only if we were asked to watch a directory,
* or if the filename filter matches.
*/
if (handle->is_path_dir || _wcsnicmp(handle->filew, file_info->FileName,
file_info->FileNameLength / sizeof(wchar_t)) == 0) {
if (handle->is_path_dir ||
_wcsnicmp(handle->filew, file_info->FileName,
file_info->FileNameLength / sizeof(wchar_t)) == 0 ||
_wcsnicmp(handle->short_filew, file_info->FileName,
file_info->FileNameLength / sizeof(wchar_t)) == 0) {
/* Convert the filename to utf8. */
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) {
handle->filew = NULL;
}
if (handle->short_filew) {
free(handle->short_filew);
handle->short_filew = NULL;
}
if (handle->filename) {
free(handle->filename);
handle->filename = NULL;

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

@ -64,8 +64,7 @@ void uv_process_timers(uv_loop_t* loop);
#define UV_HANDLE_SYNC_BYPASS_IOCP 0x20000
#define UV_HANDLE_ZERO_READ 0x40000
#define UV_HANDLE_TTY_RAW 0x80000
#define UV_HANDLE_USE_IPC_PROTOCOL 0x100000
#define UV_HANDLE_EMULATE_IOCP 0x200000
#define UV_HANDLE_EMULATE_IOCP 0x100000
void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle);
void uv_process_endgames(uv_loop_t* loop);

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

@ -78,13 +78,10 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
handle->ipc_pid = 0;
handle->remaining_ipc_rawdata_bytes = 0;
handle->pending_socket_info = NULL;
handle->ipc = ipc;
uv_req_init(loop, (uv_req_t*) &handle->ipc_header_write_req);
if (ipc) {
handle->flags |= UV_HANDLE_USE_IPC_PROTOCOL;
}
loop->counters.pipe_init++;
return 0;
@ -585,7 +582,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) {
uv_pipe_t* pipe_client;
uv_pipe_accept_t* req;
if (server->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
if (server->ipc) {
if (!server->pending_socket_info) {
/* No valid pending sockets. */
uv__set_sys_error(loop, WSAEWOULDBLOCK);
@ -780,7 +777,7 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req,
req->ipc_header = 0;
memset(&req->overlapped, 0, sizeof(req->overlapped));
if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
if (handle->ipc) {
/* Use the IPC framing protocol. */
if (send_handle) {
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,
int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
uv_buf_t bufs[], int bufcnt, uv_stream_t* send_handle, uv_write_cb cb) {
if (!(handle->flags & UV_HANDLE_USE_IPC_PROTOCOL)) {
if (!handle->ipc) {
uv__set_artificial_error(loop, UV_EINVAL);
return -1;
}
@ -983,7 +980,7 @@ void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
break;
}
if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
if (handle->ipc) {
/* Use the IPC framing protocol to read the incoming data. */
if (handle->remaining_ipc_rawdata_bytes == 0) {
/* 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,
&bytes,
NULL)) {
/* Successful read */
if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
if (handle->ipc) {
assert(handle->remaining_ipc_rawdata_bytes >= bytes);
handle->remaining_ipc_rawdata_bytes =
handle->remaining_ipc_rawdata_bytes - bytes;
@ -1280,7 +1277,7 @@ void uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
HANDLE os_handle;
/* Special-case stdin with ipc. */
if (file == 0 && pipe->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
if (file == 0 && pipe->ipc) {
os_handle = (HANDLE)_get_osfhandle(file);
if (os_handle == INVALID_HANDLE_VALUE ||

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

@ -906,7 +906,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
/* Create stdio pipes. */
if (options.stdin_stream) {
if (options.stdin_stream->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
if (options.stdin_stream->ipc) {
err = uv_create_stdio_pipe_pair(
loop,
options.stdin_stream,
@ -985,7 +985,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
process->pid = info.dwProcessId;
if (options.stdin_stream &&
options.stdin_stream->flags & UV_HANDLE_USE_IPC_PROTOCOL) {
options.stdin_stream->ipc) {
options.stdin_stream->ipc_pid = info.dwProcessId;
}

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

@ -191,6 +191,7 @@ TEST_IMPL(ipc) {
r = uv_pipe_init(uv_default_loop(), &channel, 1);
ASSERT(r == 0);
ASSERT(channel.ipc);
memset(&options, 0, sizeof(uv_process_options_t));

Loading…
Cancel
Save