| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 26c08a3 commit a23d8ad
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -300,6 +300,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); | |||
| 300 | 300 | int req_pending; \ | |
| 301 | 301 | uv_fs_event_cb cb; \ | |
| 302 | 302 | wchar_t* filew; \ | |
| 303 | + wchar_t* short_filew; \ | ||
| 303 | 304 | int is_path_dir; \ | |
| 304 | 305 | char* buffer; | |
| 305 | 306 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1063,7 +1063,11 @@ struct uv_fs_event_s { | |||
| 1063 | 1063 | }; | |
| 1064 | 1064 | ||
| 1065 | 1065 | ||
| 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 | + */ | ||
| 1067 | 1071 | void uv_loadavg(double avg[3]); | |
| 1068 | 1072 | ||
| 1069 | 1073 | /* | |
@@ -1087,7 +1091,7 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size); | |||
| 1087 | 1091 | /* Gets the executable path */ | |
| 1088 | 1092 | int uv_exepath(char* buffer, size_t* size); | |
| 1089 | 1093 | ||
| 1090 | - /* Memory info */ | ||
| 1094 | + /* Gets memory info in bytes */ | ||
| 1091 | 1095 | double uv_get_free_memory(void); | |
| 1092 | 1096 | double uv_get_total_memory(void); | |
| 1093 | 1097 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -600,11 +600,11 @@ static void uv__read(uv_stream_t* stream) { | |||
| 600 | 600 | } else { | |
| 601 | 601 | stream->read2_cb((uv_pipe_t*)stream, nread, buf, UV_UNKNOWN_HANDLE); | |
| 602 | 602 | } | |
| 603 | + } | ||
| 603 | 604 | ||
| 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; | ||
| 608 | 608 | } | |
| 609 | 609 | } | |
| 610 | 610 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,6 +105,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) { | |||
| 105 | 105 | case WSAECONNABORTED: return UV_ECONNABORTED; | |
| 106 | 106 | case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED; | |
| 107 | 107 | case WSAECONNREFUSED: return UV_ECONNREFUSED; | |
| 108 | + case ERROR_NETNAME_DELETED: return UV_ECONNRESET; | ||
| 109 | + case WSAECONNRESET: return UV_ECONNRESET; | ||
| 108 | 110 | case WSAEFAULT: return UV_EFAULT; | |
| 109 | 111 | case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH; | |
| 110 | 112 | case WSAEHOSTUNREACH: return UV_EHOSTUNREACH; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,8 @@ static void uv_fs_event_init_handle(uv_loop_t* loop, uv_fs_event_t* handle, | |||
| 41 | 41 | handle->buffer = NULL; | |
| 42 | 42 | handle->req_pending = 0; | |
| 43 | 43 | handle->filew = NULL; | |
| 44 | - | ||
| 44 | + handle->short_filew = NULL; | ||
| 45 | + | ||
| 45 | 46 | uv_req_init(loop, (uv_req_t*)&handle->req); | |
| 46 | 47 | handle->req.type = UV_FS_EVENT_REQ; | |
| 47 | 48 | handle->req.data = (void*)handle; | |
@@ -95,25 +96,29 @@ static int uv_split_path(const wchar_t* filename, wchar_t** dir, | |||
| 95 | 96 | while (i > 0 && filename[--i] != '\\' && filename[i] != '/'); | |
| 96 | 97 | ||
| 97 | 98 | 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 | + } | ||
| 107 | 110 | } | |
| 108 | 111 | ||
| 109 | 112 | *file = wcsdup(filename); | |
| 110 | 113 | } 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'; | ||
| 114 | 121 | } | |
| 115 | - wcsncpy(*dir, filename, i); | ||
| 116 | - (*dir)[i] = L'\0'; | ||
| 117 | 122 | ||
| 118 | 123 | *file = (wchar_t*)malloc((len - i) * sizeof(wchar_t)); | |
| 119 | 124 | if (!*file) { | |
@@ -132,6 +137,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle, | |||
| 132 | 137 | int name_size; | |
| 133 | 138 | DWORD attr, last_error; | |
| 134 | 139 | wchar_t* dir = NULL, *dir_to_watch, *filenamew; | |
| 140 | + wchar_t short_path[MAX_PATH]; | ||
| 135 | 141 | ||
| 136 | 142 | uv_fs_event_init_handle(loop, handle, filename, cb); | |
| 137 | 143 | ||
@@ -165,11 +171,23 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle, | |||
| 165 | 171 | * filename is a file. So we split filename into dir & file parts, and | |
| 166 | 172 | * watch the dir directory. | |
| 167 | 173 | */ | |
| 174 | + | ||
| 175 | + /* Convert to short path. */ | ||
| 176 | + if (!GetShortPathNameW(filenamew, short_path, COUNTOF(short_path))) { | ||
| 177 | + last_error = GetLastError(); | ||
| 178 | + goto error; | ||
| 179 | + } | ||
| 180 | + | ||
| 168 | 181 | if (uv_split_path(filenamew, &dir, &handle->filew) != 0) { | |
| 169 | 182 | last_error = GetLastError(); | |
| 170 | 183 | goto error; | |
| 171 | 184 | } | |
| 172 | 185 | ||
| 186 | + if (uv_split_path(short_path, NULL, &handle->short_filew) != 0) { | ||
| 187 | + last_error = GetLastError(); | ||
| 188 | + goto error; | ||
| 189 | + } | ||
| 190 | + | ||
| 173 | 191 | dir_to_watch = dir; | |
| 174 | 192 | } | |
| 175 | 193 | ||
@@ -194,9 +212,9 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle, | |||
| 194 | 212 | } | |
| 195 | 213 | ||
| 196 | 214 | 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) { | ||
| 200 | 218 | last_error = GetLastError(); | |
| 201 | 219 | goto error; | |
| 202 | 220 | } | |
@@ -242,6 +260,11 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle, | |||
| 242 | 260 | handle->filew = NULL; | |
| 243 | 261 | } | |
| 244 | 262 | ||
| 263 | + if (handle->short_filew) { | ||
| 264 | + free(handle->short_filew); | ||
| 265 | + handle->short_filew = NULL; | ||
| 266 | + } | ||
| 267 | + | ||
| 245 | 268 | if (handle->dir_handle != INVALID_HANDLE_VALUE) { | |
| 246 | 269 | CloseHandle(handle->dir_handle); | |
| 247 | 270 | handle->dir_handle = INVALID_HANDLE_VALUE; | |
@@ -279,8 +302,11 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, | |||
| 279 | 302 | * Fire the event only if we were asked to watch a directory, | |
| 280 | 303 | * or if the filename filter matches. | |
| 281 | 304 | */ | |
| 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) { | ||
| 284 | 310 | ||
| 285 | 311 | /* Convert the filename to utf8. */ | |
| 286 | 312 | 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) { | |||
| 370 | 396 | handle->filew = NULL; | |
| 371 | 397 | } | |
| 372 | 398 | ||
| 399 | + if (handle->short_filew) { | ||
| 400 | + free(handle->short_filew); | ||
| 401 | + handle->short_filew = NULL; | ||
| 402 | + } | ||
| 403 | + | ||
| 373 | 404 | if (handle->filename) { | |
| 374 | 405 | free(handle->filename); | |
| 375 | 406 | handle->filename = NULL; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,8 +64,7 @@ void uv_process_timers(uv_loop_t* loop); | |||
| 64 | 64 | #define UV_HANDLE_SYNC_BYPASS_IOCP 0x20000 | |
| 65 | 65 | #define UV_HANDLE_ZERO_READ 0x40000 | |
| 66 | 66 | #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 | ||
| 69 | 68 | ||
| 70 | 69 | void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle); | |
| 71 | 70 | void uv_process_endgames(uv_loop_t* loop); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,13 +78,10 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) { | |||
| 78 | 78 | handle->ipc_pid = 0; | |
| 79 | 79 | handle->remaining_ipc_rawdata_bytes = 0; | |
| 80 | 80 | handle->pending_socket_info = NULL; | |
| 81 | + handle->ipc = ipc; | ||
| 81 | 82 | ||
| 82 | 83 | uv_req_init(loop, (uv_req_t*) &handle->ipc_header_write_req); | |
| 83 | 84 | ||
| 84 | - if (ipc) { | ||
| 85 | - handle->flags |= UV_HANDLE_USE_IPC_PROTOCOL; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | 85 | loop->counters.pipe_init++; | |
| 89 | 86 | ||
| 90 | 87 | return 0; | |
@@ -585,7 +582,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) { | |||
| 585 | 582 | uv_pipe_t* pipe_client; | |
| 586 | 583 | uv_pipe_accept_t* req; | |
| 587 | 584 | ||
| 588 | - if (server->flags & UV_HANDLE_USE_IPC_PROTOCOL) { | ||
| 585 | + if (server->ipc) { | ||
| 589 | 586 | if (!server->pending_socket_info) { | |
| 590 | 587 | /* No valid pending sockets. */ | |
| 591 | 588 | uv__set_sys_error(loop, WSAEWOULDBLOCK); | |
@@ -780,7 +777,7 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req, | |||
| 780 | 777 | req->ipc_header = 0; | |
| 781 | 778 | memset(&req->overlapped, 0, sizeof(req->overlapped)); | |
| 782 | 779 | ||
| 783 | - if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) { | ||
| 780 | + if (handle->ipc) { | ||
| 784 | 781 | /* Use the IPC framing protocol. */ | |
| 785 | 782 | if (send_handle) { | |
| 786 | 783 | 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, | |||
| 892 | 889 | ||
| 893 | 890 | int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, | |
| 894 | 891 | 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) { | ||
| 896 | 893 | uv__set_artificial_error(loop, UV_EINVAL); | |
| 897 | 894 | return -1; | |
| 898 | 895 | } | |
@@ -983,7 +980,7 @@ void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, | |||
| 983 | 980 | break; | |
| 984 | 981 | } | |
| 985 | 982 | ||
| 986 | - if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) { | ||
| 983 | + if (handle->ipc) { | ||
| 987 | 984 | /* Use the IPC framing protocol to read the incoming data. */ | |
| 988 | 985 | if (handle->remaining_ipc_rawdata_bytes == 0) { | |
| 989 | 986 | /* 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, | |||
| 1048 | 1045 | &bytes, | |
| 1049 | 1046 | NULL)) { | |
| 1050 | 1047 | /* Successful read */ | |
| 1051 | - if (handle->flags & UV_HANDLE_USE_IPC_PROTOCOL) { | ||
| 1048 | + if (handle->ipc) { | ||
| 1052 | 1049 | assert(handle->remaining_ipc_rawdata_bytes >= bytes); | |
| 1053 | 1050 | handle->remaining_ipc_rawdata_bytes = | |
| 1054 | 1051 | handle->remaining_ipc_rawdata_bytes - bytes; | |
@@ -1280,7 +1277,7 @@ void uv_pipe_open(uv_pipe_t* pipe, uv_file file) { | |||
| 1280 | 1277 | HANDLE os_handle; | |
| 1281 | 1278 | ||
| 1282 | 1279 | /* Special-case stdin with ipc. */ | |
| 1283 | - if (file == 0 && pipe->flags & UV_HANDLE_USE_IPC_PROTOCOL) { | ||
| 1280 | + if (file == 0 && pipe->ipc) { | ||
| 1284 | 1281 | os_handle = (HANDLE)_get_osfhandle(file); | |
| 1285 | 1282 | ||
| 1286 | 1283 | if (os_handle == INVALID_HANDLE_VALUE || | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -906,7 +906,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, | |||
| 906 | 906 | ||
| 907 | 907 | /* Create stdio pipes. */ | |
| 908 | 908 | if (options.stdin_stream) { | |
| 909 | - if (options.stdin_stream->flags & UV_HANDLE_USE_IPC_PROTOCOL) { | ||
| 909 | + if (options.stdin_stream->ipc) { | ||
| 910 | 910 | err = uv_create_stdio_pipe_pair( | |
| 911 | 911 | loop, | |
| 912 | 912 | options.stdin_stream, | |
@@ -985,7 +985,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, | |||
| 985 | 985 | process->pid = info.dwProcessId; | |
| 986 | 986 | ||
| 987 | 987 | if (options.stdin_stream && | |
| 988 | - options.stdin_stream->flags & UV_HANDLE_USE_IPC_PROTOCOL) { | ||
| 988 | + options.stdin_stream->ipc) { | ||
| 989 | 989 | options.stdin_stream->ipc_pid = info.dwProcessId; | |
| 990 | 990 | } | |
| 991 | 991 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,6 +191,7 @@ TEST_IMPL(ipc) { | |||
| 191 | 191 | ||
| 192 | 192 | r = uv_pipe_init(uv_default_loop(), &channel, 1); | |
| 193 | 193 | ASSERT(r == 0); | |
| 194 | + ASSERT(channel.ipc); | ||
| 194 | 195 | ||
| 195 | 196 | memset(&options, 0, sizeof(uv_process_options_t)); | |
| 196 | 197 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments