Skip to content

Commit f178f2a

Browse files
author
Igor Zinkovsky
committed
upgrade libuv to d68b3d960b6d95bfc16027cecca2f3fa48bcc36f
1 parent 052aaa4 commit f178f2a

File tree

13 files changed

+292
-41
lines changed

13 files changed

+292
-41
lines changed

deps/uv/include/uv.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,12 +1155,18 @@ UV_EXTERN int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path,
11551155
UV_EXTERN int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file,
11561156
void* buf, size_t length, off_t offset, uv_fs_cb cb);
11571157

1158+
int uv_fs_read64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1159+
void* buf, size_t length, int64_t offset, uv_fs_cb cb);
1160+
11581161
UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
11591162
uv_fs_cb cb);
11601163

11611164
UV_EXTERN int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file,
11621165
void* buf, size_t length, off_t offset, uv_fs_cb cb);
11631166

1167+
int uv_fs_write64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1168+
void* buf, size_t length, int64_t offset, uv_fs_cb cb);
1169+
11641170
UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
11651171
int mode, uv_fs_cb cb);
11661172

@@ -1188,6 +1194,9 @@ UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file,
11881194
UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
11891195
off_t offset, uv_fs_cb cb);
11901196

1197+
int uv_fs_ftruncate64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1198+
int64_t offset, uv_fs_cb cb);
1199+
11911200
UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd,
11921201
uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb);
11931202

deps/uv/src/unix/fs.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,3 +701,34 @@ int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb,
701701

702702
return 0;
703703
}
704+
705+
706+
int uv_fs_read64(uv_loop_t* loop,
707+
uv_fs_t* req,
708+
uv_file file,
709+
void* buf,
710+
size_t length,
711+
int64_t offset,
712+
uv_fs_cb cb) {
713+
return uv_fs_read(loop, req, file, buf, length, offset, cb);
714+
}
715+
716+
717+
int uv_fs_write64(uv_loop_t* loop,
718+
uv_fs_t* req,
719+
uv_file file,
720+
void* buf,
721+
size_t length,
722+
int64_t offset,
723+
uv_fs_cb cb) {
724+
return uv_fs_write(loop, req, file, buf, length, offset, cb);
725+
}
726+
727+
728+
int uv_fs_ftruncate64(uv_loop_t* loop,
729+
uv_fs_t* req,
730+
uv_file file,
731+
int64_t offset,
732+
uv_fs_cb cb) {
733+
return uv_fs_ftruncate(loop, req, file, offset, cb);
734+
}

deps/uv/src/win/error.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
125125
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
126126
case WSAETIMEDOUT: return UV_ETIMEDOUT;
127127
case WSAHOST_NOT_FOUND: return UV_ENOENT;
128+
case WSAENOTSOCK: return UV_ENOTSOCK;
128129
default: return UV_UNKNOWN;
129130
}
130131
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
301301
assert(handle->req_pending);
302302
handle->req_pending = 0;
303303

304+
/* If we're closing, don't report any callbacks, and just push the handle */
305+
/* onto the endgame queue. */
306+
if (handle->flags & UV_HANDLE_CLOSING) {
307+
uv_want_endgame(loop, (uv_handle_t*) handle);
308+
return;
309+
};
310+
304311
file_info = (FILE_NOTIFY_INFORMATION*)(handle->buffer + offset);
305312

306313
if (REQ_SUCCESS(req)) {
@@ -438,11 +445,9 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
438445
}
439446

440447
offset = file_info->NextEntryOffset;
441-
} while(offset);
448+
} while (offset && !(handle->flags & UV_HANDLE_CLOSING));
442449
} else {
443-
if (!(handle->flags & UV_HANDLE_CLOSING)) {
444-
handle->cb(handle, NULL, UV_CHANGE, 0);
445-
}
450+
handle->cb(handle, NULL, UV_CHANGE, 0);
446451
}
447452
} else {
448453
uv__set_sys_error(loop, GET_REQ_ERROR(req));

deps/uv/src/win/fs.c

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@
3333
#include "uv.h"
3434
#include "internal.h"
3535

36-
#define UV_FS_ASYNC_QUEUED 0x0001
37-
#define UV_FS_FREE_ARG0 0x0002
38-
#define UV_FS_FREE_ARG1 0x0004
39-
#define UV_FS_FREE_PTR 0x0008
40-
#define UV_FS_CLEANEDUP 0x0010
41-
36+
#define UV_FS_ASYNC_QUEUED 0x0001
37+
#define UV_FS_FREE_ARG0 0x0002
38+
#define UV_FS_FREE_ARG1 0x0004
39+
#define UV_FS_FREE_PTR 0x0008
40+
#define UV_FS_CLEANEDUP 0x0010
4241

4342
#define UTF8_TO_UTF16(s, t) \
4443
size = uv_utf8_to_utf16(s, NULL, 0) * sizeof(wchar_t); \
@@ -289,7 +288,7 @@ void fs__close(uv_fs_t* req, uv_file file) {
289288

290289

291290
void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
292-
off_t offset) {
291+
int64_t offset) {
293292
HANDLE handle;
294293
OVERLAPPED overlapped, *overlapped_ptr;
295294
LARGE_INTEGER offset_;
@@ -335,7 +334,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
335334

336335

337336
void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
338-
off_t offset) {
337+
int64_t offset) {
339338
HANDLE handle;
340339
OVERLAPPED overlapped, *overlapped_ptr;
341340
LARGE_INTEGER offset_;
@@ -597,12 +596,12 @@ void fs__fsync(uv_fs_t* req, uv_file file) {
597596
}
598597

599598

600-
void fs__ftruncate(uv_fs_t* req, uv_file file, off_t offset) {
599+
void fs__ftruncate(uv_fs_t* req, uv_file file, int64_t offset) {
601600
int result;
602601

603602
VERIFY_UV_FILE(file, req);
604603

605-
result = _chsize(file, offset);
604+
result = _chsize_s(file, offset);
606605
SET_REQ_RESULT(req, result);
607606
}
608607

@@ -878,14 +877,14 @@ static DWORD WINAPI uv_fs_thread_proc(void* parameter) {
878877
(uv_file) req->arg0,
879878
req->arg1,
880879
(size_t) req->arg2,
881-
(off_t) req->arg3);
880+
req->stat.st_atime);
882881
break;
883882
case UV_FS_WRITE:
884883
fs__write(req,
885884
(uv_file)req->arg0,
886885
req->arg1,
887886
(size_t) req->arg2,
888-
(off_t) req->arg3);
887+
req->stat.st_atime);
889888
break;
890889
case UV_FS_UNLINK:
891890
fs__unlink(req, req->pathw);
@@ -914,7 +913,7 @@ static DWORD WINAPI uv_fs_thread_proc(void* parameter) {
914913
fs__fsync(req, (uv_file)req->arg0);
915914
break;
916915
case UV_FS_FTRUNCATE:
917-
fs__ftruncate(req, (uv_file)req->arg0, (off_t)req->arg1);
916+
fs__ftruncate(req, (uv_file)req->arg0, (off_t)req->stat.st_atime);
918917
break;
919918
case UV_FS_SENDFILE:
920919
fs__sendfile(req,
@@ -1002,7 +1001,26 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
10021001
size_t length, off_t offset, uv_fs_cb cb) {
10031002
if (cb) {
10041003
uv_fs_req_init_async(loop, req, UV_FS_READ, NULL, NULL, cb);
1005-
WRAP_REQ_ARGS4(req, file, buf, length, offset);
1004+
WRAP_REQ_ARGS3(req, file, buf, length);
1005+
req->stat.st_atime = offset;
1006+
QUEUE_FS_TP_JOB(loop, req);
1007+
} else {
1008+
uv_fs_req_init_sync(loop, req, UV_FS_READ);
1009+
fs__read(req, file, buf, length, offset);
1010+
SET_UV_LAST_ERROR_FROM_REQ(req);
1011+
return req->result;
1012+
}
1013+
1014+
return 0;
1015+
}
1016+
1017+
1018+
int uv_fs_read64(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
1019+
size_t length, int64_t offset, uv_fs_cb cb) {
1020+
if (cb) {
1021+
uv_fs_req_init_async(loop, req, UV_FS_READ, NULL, NULL, cb);
1022+
WRAP_REQ_ARGS3(req, file, buf, length);
1023+
req->stat.st_atime = offset;
10061024
QUEUE_FS_TP_JOB(loop, req);
10071025
} else {
10081026
uv_fs_req_init_sync(loop, req, UV_FS_READ);
@@ -1019,7 +1037,26 @@ int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
10191037
size_t length, off_t offset, uv_fs_cb cb) {
10201038
if (cb) {
10211039
uv_fs_req_init_async(loop, req, UV_FS_WRITE, NULL, NULL, cb);
1022-
WRAP_REQ_ARGS4(req, file, buf, length, offset);
1040+
WRAP_REQ_ARGS3(req, file, buf, length);
1041+
req->stat.st_atime = offset;
1042+
QUEUE_FS_TP_JOB(loop, req);
1043+
} else {
1044+
uv_fs_req_init_sync(loop, req, UV_FS_WRITE);
1045+
fs__write(req, file, buf, length, offset);
1046+
SET_UV_LAST_ERROR_FROM_REQ(req);
1047+
return req->result;
1048+
}
1049+
1050+
return 0;
1051+
}
1052+
1053+
1054+
int uv_fs_write64(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
1055+
size_t length, int64_t offset, uv_fs_cb cb) {
1056+
if (cb) {
1057+
uv_fs_req_init_async(loop, req, UV_FS_WRITE, NULL, NULL, cb);
1058+
WRAP_REQ_ARGS3(req, file, buf, length);
1059+
req->stat.st_atime = offset;
10231060
QUEUE_FS_TP_JOB(loop, req);
10241061
} else {
10251062
uv_fs_req_init_sync(loop, req, UV_FS_WRITE);
@@ -1412,7 +1449,26 @@ int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
14121449
off_t offset, uv_fs_cb cb) {
14131450
if (cb) {
14141451
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, NULL, NULL, cb);
1415-
WRAP_REQ_ARGS2(req, file, offset);
1452+
WRAP_REQ_ARGS1(req, file);
1453+
req->stat.st_atime = offset;
1454+
QUEUE_FS_TP_JOB(loop, req);
1455+
} else {
1456+
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE);
1457+
fs__ftruncate(req, file, offset);
1458+
SET_UV_LAST_ERROR_FROM_REQ(req);
1459+
return req->result;
1460+
}
1461+
1462+
return 0;
1463+
}
1464+
1465+
1466+
int uv_fs_ftruncate64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1467+
int64_t offset, uv_fs_cb cb) {
1468+
if (cb) {
1469+
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, NULL, NULL, cb);
1470+
WRAP_REQ_ARGS1(req, file);
1471+
req->stat.st_atime = offset;
14161472
QUEUE_FS_TP_JOB(loop, req);
14171473
} else {
14181474
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE);

deps/uv/src/win/pipe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ static int uv_set_pipe_handle(uv_loop_t* loop, uv_pipe_t* handle,
217217
DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;
218218

219219
if (!SetNamedPipeHandleState(pipeHandle, &mode, NULL, NULL)) {
220+
/* If this returns ERROR_INVALID_PARAMETER we probably opened something */
221+
/* that is not a pipe. */
222+
if (GetLastError() == ERROR_INVALID_PARAMETER) {
223+
SetLastError(WSAENOTSOCK);
224+
}
220225
return -1;
221226
}
222227

deps/uv/src/win/tcp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,9 @@ static int uv__bind(uv_tcp_t* handle,
239239
int addrsize) {
240240
DWORD err;
241241
int r;
242-
SOCKET sock;
243242

244243
if (handle->socket == INVALID_SOCKET) {
245-
sock = socket(domain, SOCK_STREAM, 0);
244+
SOCKET sock = socket(domain, SOCK_STREAM, 0);
246245
if (sock == INVALID_SOCKET) {
247246
uv__set_sys_error(handle->loop, WSAGetLastError());
248247
return -1;

deps/uv/src/win/udp.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ static int uv__bind(uv_udp_t* handle,
167167
int addrsize,
168168
unsigned int flags) {
169169
int r;
170-
SOCKET sock;
171170
DWORD no = 0, yes = 1;
172171

173172
if ((flags & UV_UDP_IPV6ONLY) && domain != AF_INET6) {
@@ -177,7 +176,7 @@ static int uv__bind(uv_udp_t* handle,
177176
}
178177

179178
if (handle->socket == INVALID_SOCKET) {
180-
sock = socket(domain, SOCK_DGRAM, 0);
179+
SOCKET sock = socket(domain, SOCK_DGRAM, 0);
181180
if (sock == INVALID_SOCKET) {
182181
uv__set_sys_error(handle->loop, WSAGetLastError());
183182
return -1;
@@ -196,14 +195,14 @@ static int uv__bind(uv_udp_t* handle,
196195
/* TODO: how to handle errors? This may fail if there is no ipv4 stack */
197196
/* available, or when run on XP/2003 which have no support for dualstack */
198197
/* sockets. For now we're silently ignoring the error. */
199-
setsockopt(sock,
198+
setsockopt(handle->socket,
200199
IPPROTO_IPV6,
201200
IPV6_V6ONLY,
202201
(char*) &no,
203202
sizeof no);
204203
}
205204

206-
r = setsockopt(sock,
205+
r = setsockopt(handle->socket,
207206
SOL_SOCKET,
208207
SO_REUSEADDR,
209208
(char*) &yes,

0 commit comments

Comments
 (0)