Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
upgrade libuv to d68b3d960b6d95bfc16027cecca2f3fa48bcc36f
  • Loading branch information
Igor Zinkovsky committed Apr 6, 2012
1 parent 052aaa4 commit f178f2a
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 41 deletions.
9 changes: 9 additions & 0 deletions deps/uv/include/uv.h
Expand Up @@ -1155,12 +1155,18 @@ UV_EXTERN int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path,
UV_EXTERN int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file,
void* buf, size_t length, off_t offset, uv_fs_cb cb);

int uv_fs_read64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
void* buf, size_t length, int64_t offset, uv_fs_cb cb);

UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb);

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

int uv_fs_write64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
void* buf, size_t length, int64_t offset, uv_fs_cb cb);

UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
int mode, uv_fs_cb cb);

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

int uv_fs_ftruncate64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
int64_t offset, uv_fs_cb cb);

UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd,
uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb);

Expand Down
31 changes: 31 additions & 0 deletions deps/uv/src/unix/fs.c
Expand Up @@ -701,3 +701,34 @@ int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb,

return 0;
}


int uv_fs_read64(uv_loop_t* loop,
uv_fs_t* req,
uv_file file,
void* buf,
size_t length,
int64_t offset,
uv_fs_cb cb) {
return uv_fs_read(loop, req, file, buf, length, offset, cb);
}


int uv_fs_write64(uv_loop_t* loop,
uv_fs_t* req,
uv_file file,
void* buf,
size_t length,
int64_t offset,
uv_fs_cb cb) {
return uv_fs_write(loop, req, file, buf, length, offset, cb);
}


int uv_fs_ftruncate64(uv_loop_t* loop,
uv_fs_t* req,
uv_file file,
int64_t offset,
uv_fs_cb cb) {
return uv_fs_ftruncate(loop, req, file, offset, cb);
}
1 change: 1 addition & 0 deletions deps/uv/src/win/error.c
Expand Up @@ -125,6 +125,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
case WSAETIMEDOUT: return UV_ETIMEDOUT;
case WSAHOST_NOT_FOUND: return UV_ENOENT;
case WSAENOTSOCK: return UV_ENOTSOCK;
default: return UV_UNKNOWN;
}
}
Expand Down
13 changes: 9 additions & 4 deletions deps/uv/src/win/fs-event.c
Expand Up @@ -301,6 +301,13 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
assert(handle->req_pending);
handle->req_pending = 0;

/* If we're closing, don't report any callbacks, and just push the handle */
/* onto the endgame queue. */
if (handle->flags & UV_HANDLE_CLOSING) {
uv_want_endgame(loop, (uv_handle_t*) handle);
return;
};

file_info = (FILE_NOTIFY_INFORMATION*)(handle->buffer + offset);

if (REQ_SUCCESS(req)) {
Expand Down Expand Up @@ -438,11 +445,9 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
}

offset = file_info->NextEntryOffset;
} while(offset);
} while (offset && !(handle->flags & UV_HANDLE_CLOSING));
} else {
if (!(handle->flags & UV_HANDLE_CLOSING)) {
handle->cb(handle, NULL, UV_CHANGE, 0);
}
handle->cb(handle, NULL, UV_CHANGE, 0);
}
} else {
uv__set_sys_error(loop, GET_REQ_ERROR(req));
Expand Down
88 changes: 72 additions & 16 deletions deps/uv/src/win/fs.c
Expand Up @@ -33,12 +33,11 @@
#include "uv.h"
#include "internal.h"

#define UV_FS_ASYNC_QUEUED 0x0001
#define UV_FS_FREE_ARG0 0x0002
#define UV_FS_FREE_ARG1 0x0004
#define UV_FS_FREE_PTR 0x0008
#define UV_FS_CLEANEDUP 0x0010

#define UV_FS_ASYNC_QUEUED 0x0001
#define UV_FS_FREE_ARG0 0x0002
#define UV_FS_FREE_ARG1 0x0004
#define UV_FS_FREE_PTR 0x0008
#define UV_FS_CLEANEDUP 0x0010

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


void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
off_t offset) {
int64_t offset) {
HANDLE handle;
OVERLAPPED overlapped, *overlapped_ptr;
LARGE_INTEGER offset_;
Expand Down Expand Up @@ -335,7 +334,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,


void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
off_t offset) {
int64_t offset) {
HANDLE handle;
OVERLAPPED overlapped, *overlapped_ptr;
LARGE_INTEGER offset_;
Expand Down Expand Up @@ -597,12 +596,12 @@ void fs__fsync(uv_fs_t* req, uv_file file) {
}


void fs__ftruncate(uv_fs_t* req, uv_file file, off_t offset) {
void fs__ftruncate(uv_fs_t* req, uv_file file, int64_t offset) {
int result;

VERIFY_UV_FILE(file, req);

result = _chsize(file, offset);
result = _chsize_s(file, offset);
SET_REQ_RESULT(req, result);
}

Expand Down Expand Up @@ -878,14 +877,14 @@ static DWORD WINAPI uv_fs_thread_proc(void* parameter) {
(uv_file) req->arg0,
req->arg1,
(size_t) req->arg2,
(off_t) req->arg3);
req->stat.st_atime);
break;
case UV_FS_WRITE:
fs__write(req,
(uv_file)req->arg0,
req->arg1,
(size_t) req->arg2,
(off_t) req->arg3);
req->stat.st_atime);
break;
case UV_FS_UNLINK:
fs__unlink(req, req->pathw);
Expand Down Expand Up @@ -914,7 +913,7 @@ static DWORD WINAPI uv_fs_thread_proc(void* parameter) {
fs__fsync(req, (uv_file)req->arg0);
break;
case UV_FS_FTRUNCATE:
fs__ftruncate(req, (uv_file)req->arg0, (off_t)req->arg1);
fs__ftruncate(req, (uv_file)req->arg0, (off_t)req->stat.st_atime);
break;
case UV_FS_SENDFILE:
fs__sendfile(req,
Expand Down Expand Up @@ -1002,7 +1001,26 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
size_t length, off_t offset, uv_fs_cb cb) {
if (cb) {
uv_fs_req_init_async(loop, req, UV_FS_READ, NULL, NULL, cb);
WRAP_REQ_ARGS4(req, file, buf, length, offset);
WRAP_REQ_ARGS3(req, file, buf, length);
req->stat.st_atime = offset;
QUEUE_FS_TP_JOB(loop, req);
} else {
uv_fs_req_init_sync(loop, req, UV_FS_READ);
fs__read(req, file, buf, length, offset);
SET_UV_LAST_ERROR_FROM_REQ(req);
return req->result;
}

return 0;
}


int uv_fs_read64(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
size_t length, int64_t offset, uv_fs_cb cb) {
if (cb) {
uv_fs_req_init_async(loop, req, UV_FS_READ, NULL, NULL, cb);
WRAP_REQ_ARGS3(req, file, buf, length);
req->stat.st_atime = offset;
QUEUE_FS_TP_JOB(loop, req);
} else {
uv_fs_req_init_sync(loop, req, UV_FS_READ);
Expand All @@ -1019,7 +1037,26 @@ int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
size_t length, off_t offset, uv_fs_cb cb) {
if (cb) {
uv_fs_req_init_async(loop, req, UV_FS_WRITE, NULL, NULL, cb);
WRAP_REQ_ARGS4(req, file, buf, length, offset);
WRAP_REQ_ARGS3(req, file, buf, length);
req->stat.st_atime = offset;
QUEUE_FS_TP_JOB(loop, req);
} else {
uv_fs_req_init_sync(loop, req, UV_FS_WRITE);
fs__write(req, file, buf, length, offset);
SET_UV_LAST_ERROR_FROM_REQ(req);
return req->result;
}

return 0;
}


int uv_fs_write64(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
size_t length, int64_t offset, uv_fs_cb cb) {
if (cb) {
uv_fs_req_init_async(loop, req, UV_FS_WRITE, NULL, NULL, cb);
WRAP_REQ_ARGS3(req, file, buf, length);
req->stat.st_atime = offset;
QUEUE_FS_TP_JOB(loop, req);
} else {
uv_fs_req_init_sync(loop, req, UV_FS_WRITE);
Expand Down Expand Up @@ -1412,7 +1449,26 @@ int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
off_t offset, uv_fs_cb cb) {
if (cb) {
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, NULL, NULL, cb);
WRAP_REQ_ARGS2(req, file, offset);
WRAP_REQ_ARGS1(req, file);
req->stat.st_atime = offset;
QUEUE_FS_TP_JOB(loop, req);
} else {
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE);
fs__ftruncate(req, file, offset);
SET_UV_LAST_ERROR_FROM_REQ(req);
return req->result;
}

return 0;
}


int uv_fs_ftruncate64(uv_loop_t* loop, uv_fs_t* req, uv_file file,
int64_t offset, uv_fs_cb cb) {
if (cb) {
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, NULL, NULL, cb);
WRAP_REQ_ARGS1(req, file);
req->stat.st_atime = offset;
QUEUE_FS_TP_JOB(loop, req);
} else {
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE);
Expand Down
5 changes: 5 additions & 0 deletions deps/uv/src/win/pipe.c
Expand Up @@ -217,6 +217,11 @@ static int uv_set_pipe_handle(uv_loop_t* loop, uv_pipe_t* handle,
DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;

if (!SetNamedPipeHandleState(pipeHandle, &mode, NULL, NULL)) {
/* If this returns ERROR_INVALID_PARAMETER we probably opened something */
/* that is not a pipe. */
if (GetLastError() == ERROR_INVALID_PARAMETER) {
SetLastError(WSAENOTSOCK);
}
return -1;
}

Expand Down
3 changes: 1 addition & 2 deletions deps/uv/src/win/tcp.c
Expand Up @@ -239,10 +239,9 @@ static int uv__bind(uv_tcp_t* handle,
int addrsize) {
DWORD err;
int r;
SOCKET sock;

if (handle->socket == INVALID_SOCKET) {
sock = socket(domain, SOCK_STREAM, 0);
SOCKET sock = socket(domain, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET) {
uv__set_sys_error(handle->loop, WSAGetLastError());
return -1;
Expand Down
7 changes: 3 additions & 4 deletions deps/uv/src/win/udp.c
Expand Up @@ -167,7 +167,6 @@ static int uv__bind(uv_udp_t* handle,
int addrsize,
unsigned int flags) {
int r;
SOCKET sock;
DWORD no = 0, yes = 1;

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

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

r = setsockopt(sock,
r = setsockopt(handle->socket,
SOL_SOCKET,
SO_REUSEADDR,
(char*) &yes,
Expand Down

0 comments on commit f178f2a

Please sign in to comment.