Commit 90f3c512 authored by Jérémy Lal's avatar Jérémy Lal

Imported Upstream version 0.6.16~dfsg1

parent f279fd05
......@@ -272,3 +272,5 @@ tedsuo <ted@radicaldesigns.org>
Joshua Holbrook <josh.holbrook@gmail.com>
Rod Vagg <rod@vagg.org>
Bryan Cantrill <bryan@joyent.com>
lrn@chromium.org <lrn@chromium.org>
Dane Springmeyer <dane@dbsgeo.com>
2012.03.22 Version 0.6.14 (stable)
2012.04.30 Version 0.6.16 (stable)
* Upgrade V8 to 3.6.6.25
* Upgrade npm to 1.1.18
* Windows: add mappings for UV_ENOENT (Bert Belder)
* linux: add IN_MOVE_SELF to inotify event mask (Ben Noordhuis)
* unix: call pipe handle connection cb on accept() error (Ben Noordhuis)
* unix: handle EWOULDBLOCK (Ben Noordhuis)
* map EWOULDBLOCK to UV_EAGAIN (Ben Noordhuis)
* Map ENOMEM to UV_ENOMEM (isaacs)
* Child process: support the `gid` and `uid` options (Bert Belder)
* test: cluster: add worker death event test (Ben Noordhuis)
* typo in node_http_parser (isaacs)
* http_parser: Eat CRLF between requests, even on connection:close. (Ben Noordhuis)
* don't check return value of unsetenv (Ben Noordhuis)
2012.04.09 Version 0.6.15 (stable), f160a45b254e591eb33716311c92be533c6d86c4
* Update npm to 1.1.16
* Show licenses in binary installers.
* unix: add uv_fs_read64, uv_fs_write64 and uv_fs_ftruncate64 (Ben Noordhuis)
* add 64bit offset fs functions (Igor Zinkovsky)
* windows: don't report ENOTSOCK when attempting to bind an udp handle twice (Bert Belder)
* windows: backport pipe-connect-to-file fixes from master (Bert Belder)
* windows: never call fs event callbacks after closing the watcher (Bert Belder)
* fs.readFile: don't make the callback before the fd is closed (Bert Belder)
* windows: use 64bit offsets for uv_fs apis (Igor Zinkovsky)
* Fix #2061: segmentation fault on OS X due to stat size mismatch (Ben Noordhuis)
2012.03.22 Version 0.6.14 (stable), e513ffef7549a56a5af728e1f0c2c0c8f290518a
* net: don't crash when queued write fails (Igor Zinkovsky)
......
This diff is collapsed.
......@@ -100,6 +100,7 @@ website_files = \
out/doc/about/index.html \
out/doc/community/index.html \
out/doc/logos/index.html \
out/doc/changelog.html \
$(doc_images)
doc: program $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/
......@@ -110,6 +111,9 @@ $(apidoc_dirs):
out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
cp $< $@
out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh
bash tools/build-changelog.sh
out/doc/%.html: doc/%.html
cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
......@@ -122,10 +126,22 @@ out/doc/api/%.json: doc/api/%.markdown
out/doc/api/%.html: doc/api/%.markdown
out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@
out/doc/%:
email.md: ChangeLog tools/email-footer.md
bash tools/changelog-head.sh > $@
cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
blog.html: email.md
cat $< | ./node tools/doc/node_modules/.bin/marked > $@
website-upload: doc
rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
ssh node@nodejs.org '\
rm -f ~/web/nodejs.org/dist/latest &&\
ln -s $(VERSION) ~/web/nodejs.org/dist/latest &&\
rm -f ~/web/nodejs.org/docs/latest &&\
ln -s $(VERSION) ~/web/nodejs.org/docs/latest &&\
rm -f ~/web/nodejs.org/dist/node-latest.tar.gz &&\
ln -s $(VERSION)/node-$(VERSION).tar.gz ~/web/nodejs.org/dist/node-latest.tar.gz'
docopen: out/doc/api/all.html
-google-chrome out/doc/api/all.html
......@@ -136,11 +152,13 @@ docclean:
clean:
$(WAF) clean
-find tools -name "*.pyc" | xargs rm -f
-rm -rf blog.html email.md
distclean: docclean
-find tools -name "*.pyc" | xargs rm -f
-rm -rf dist-osx
-rm -rf out/ node node_g
-rm -rf blog.html email.md
check:
@tools/waf-light check
......
......@@ -27,7 +27,7 @@
}],
],
'Optimization': 0, # /Od, no optimization
'MinimalRebuild': 'true',
'MinimalRebuild': 'false',
'OmitFramePointers': 'false',
'BasicRuntimeChecks': 3, # /RTC1
},
......
......@@ -433,6 +433,9 @@ size_t http_parser_execute (http_parser *parser,
/* this state is used after a 'Connection: close' message
* the parser will error out if it reads another message
*/
if (ch == CR || ch == LF)
break;
SET_ERRNO(HPE_CLOSED_CONNECTION);
goto error;
......
......@@ -680,6 +680,56 @@ const struct message requests[] =
,.body= ""
}
/* see https://github.com/ry/http-parser/issues/47 */
#define EAT_TRAILING_CRLF_NO_CONNECTION_CLOSE 28
, {.name = "eat CRLF between requests, no \"Connection: close\" header"
,.raw= "POST / HTTP/1.1\r\n"
"Host: www.example.com\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: 4\r\n"
"\r\n"
"q=42\r\n" /* note the trailing CRLF */
,.should_keep_alive= TRUE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.method= HTTP_POST
,.request_url= "/"
,.num_headers= 3
,.upgrade= 0
,.headers= { { "Host", "www.example.com" }
, { "Content-Type", "application/x-www-form-urlencoded" }
, { "Content-Length", "4" }
}
,.body= "q=42"
}
/* see https://github.com/ry/http-parser/issues/47 */
#define EAT_TRAILING_CRLF_WITH_CONNECTION_CLOSE 29
, {.name = "eat CRLF between requests even if \"Connection: close\" is set"
,.raw= "POST / HTTP/1.1\r\n"
"Host: www.example.com\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: 4\r\n"
"Connection: close\r\n"
"\r\n"
"q=42\r\n" /* note the trailing CRLF */
,.should_keep_alive= FALSE
,.message_complete_on_eof= FALSE /* input buffer isn't empty when on_message_complete is called */
,.http_major= 1
,.http_minor= 1
,.method= HTTP_POST
,.request_url= "/"
,.num_headers= 4
,.upgrade= 0
,.headers= { { "Host", "www.example.com" }
, { "Content-Type", "application/x-www-form-urlencoded" }
, { "Content-Length", "4" }
, { "Connection", "close" }
}
,.body= "q=42"
}
, {.name= NULL } /* sentinel */
};
......
......@@ -50,7 +50,7 @@ endif
ifeq (Darwin,$(uname_S))
EV_CONFIG=config_darwin.h
EIO_CONFIG=config_darwin.h
CPPFLAGS += -Isrc/ares/config_darwin
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 -Isrc/ares/config_darwin
LINKFLAGS+=-framework CoreServices
OBJS += src/unix/darwin.o
OBJS += src/unix/kqueue.o
......
......@@ -33,6 +33,7 @@
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <pwd.h>
#include <termios.h>
/* Note: May be cast to struct iovec. See writev(2). */
......@@ -43,6 +44,10 @@ typedef struct {
typedef int uv_file;
/* Platform-specific definitions for uv_spawn support. */
typedef gid_t uv_gid_t;
typedef uid_t uv_uid_t;
/* Platform-specific definitions for uv_dlopen support. */
typedef void* uv_lib_t;
#define UV_DYNAMIC /* empty */
......
......@@ -137,6 +137,10 @@ typedef struct uv_buf_t {
typedef int uv_file;
/* Platform-specific definitions for uv_spawn support. */
typedef unsigned char uv_uid_t;
typedef unsigned char uv_gid_t;
/* Platform-specific definitions for uv_dlopen support. */
typedef HMODULE uv_lib_t;
#define UV_DYNAMIC FAR WINAPI
......
......@@ -1058,6 +1058,34 @@ struct uv_process_s {
UV_EXTERN int uv_spawn(uv_loop_t*, uv_process_t*,
uv_process_options_t options);
/* Temporary fix for node. Do no use. */
enum uv_process_flags {
UV_PROCESS_SETUID = (1 << 0),
UV_PROCESS_SETGID = (1 << 1),
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2)
};
/* Temporary fix for node. Do not use. */
typedef struct uv_process_options2_s {
uv_exit_cb exit_cb; /* Called after the process exits. */
const char* file; /* Path to program to execute. */
char** args;
char** env;
char* cwd;
unsigned int flags;
uv_pipe_t* stdin_stream;
uv_pipe_t* stdout_stream;
uv_pipe_t* stderr_stream;
uv_uid_t uid;
uv_gid_t gid;
} uv_process_options2_t;
/* Temporary fix for node. Do not use. */
UV_EXTERN int uv_spawn2(uv_loop_t*, uv_process_t*,
uv_process_options2_t options);
/*
* Kills the process with the specified signal. The user must still
* call uv_close on the process.
......@@ -1155,12 +1183,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);
......@@ -1188,6 +1222,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);
......
......@@ -68,6 +68,9 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EBADF: return UV_EBADF;
case EPIPE: return UV_EPIPE;
case EAGAIN: return UV_EAGAIN;
#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK: return UV_EAGAIN;
#endif
case ECONNRESET: return UV_ECONNRESET;
case EFAULT: return UV_EFAULT;
case EMFILE: return UV_EMFILE;
......@@ -91,6 +94,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EBUSY: return UV_EBUSY;
case ENOTEMPTY: return UV_ENOTEMPTY;
case ENOSPC: return UV_ENOSPC;
case ENOMEM: return UV_ENOMEM;
default: return UV_UNKNOWN;
}
......
......@@ -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);
}
......@@ -271,6 +271,7 @@ int uv_fs_event_init(uv_loop_t* loop,
| IN_MODIFY
| IN_DELETE
| IN_DELETE_SELF
| IN_MOVE_SELF
| IN_MOVED_FROM
| IN_MOVED_TO;
......
......@@ -254,16 +254,15 @@ void uv__pipe_accept(EV_P_ ev_io* watcher, int revents) {
sockfd = uv__accept(pipe->fd, (struct sockaddr *)&saddr, sizeof saddr);
if (sockfd == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
assert(0 && "EAGAIN on uv__accept(pipefd)");
} else {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
uv__set_sys_error(pipe->loop, errno);
pipe->connection_cb((uv_stream_t*)pipe, -1);
}
} else {
pipe->accepted_fd = sockfd;
pipe->connection_cb((uv_stream_t*)pipe, 0);
if (pipe->accepted_fd == sockfd) {
/* The user hasn't yet accepted called uv_accept() */
/* The user hasn't called uv_accept() yet */
ev_io_stop(pipe->loop->ev, &pipe->read_watcher);
}
}
......
......@@ -161,8 +161,8 @@ static int uv__process_init_pipe(uv_pipe_t* handle, int fds[2], int flags) {
# define SPAWN_WAIT_EXEC 1
#endif
int uv_spawn(uv_loop_t* loop, uv_process_t* process,
uv_process_options_t options) {
int uv_spawn2(uv_loop_t* loop, uv_process_t* process,
uv_process_options2_t options) {
/*
* Save environ in the case that we get it clobbered
* by the child process.
......@@ -179,6 +179,12 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
pid_t pid;
int flags;
assert(options.file != NULL);
assert(!(options.flags & ~(UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS |
UV_PROCESS_SETGID |
UV_PROCESS_SETUID)));
uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS);
loop->counters.process_init++;
......@@ -268,6 +274,16 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
_exit(127);
}
if ((options.flags & UV_PROCESS_SETGID) && setgid(options.gid)) {
perror("setgid()");
_exit(127);
}
if ((options.flags & UV_PROCESS_SETUID) && setuid(options.uid)) {
perror("setuid()");
_exit(127);
}
environ = options.env;
execvp(options.file, options.args);
......
......@@ -176,7 +176,7 @@ void uv__server_io(EV_P_ ev_io* watcher, int revents) {
fd = uv__accept(stream->fd, (struct sockaddr*)&addr, sizeof addr);
if (fd < 0) {
if (errno == EAGAIN) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* No problem. */
return;
} else if (errno == EMFILE) {
......@@ -416,7 +416,7 @@ start:
}
if (n < 0) {
if (errno != EAGAIN) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
/* Error */
req->error = errno;
stream->write_queue_size -= uv__write_req_size(req);
......@@ -562,7 +562,7 @@ static void uv__read(uv_stream_t* stream) {
if (nread < 0) {
/* Error */
if (errno == EAGAIN) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* Wait for the next one. */
if (stream->flags & UV_READING) {
ev_io_start(ev, &stream->read_watcher);
......
......@@ -261,3 +261,29 @@ int uv_tcp_connect6(uv_connect_t* req,
return uv__tcp_connect6(req, handle, address, cb);
}
/* Thunk that converts uv_process_options_t into uv_process_options2_t, */
/* and then calls uv_spawn2. */
int uv_spawn(uv_loop_t* loop, uv_process_t* process,
uv_process_options_t options) {
uv_process_options2_t options2;
options2.exit_cb = options.exit_cb;
options2.file = options.file;
options2.args = options.args;
options2.cwd = options.cwd;
options2.env = options.env;
options2.stdin_stream = options.stdin_stream;
options2.stdout_stream = options.stdout_stream;
options2.stderr_stream = options.stderr_stream;
options2.flags = 0;
if (options.windows_verbatim_arguments) {
options2.flags |= UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS;
}
/* No need to set gid and uid. */
return uv_spawn2(loop, process, options2);
}
......@@ -68,6 +68,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
switch (sys_errno) {
case ERROR_SUCCESS: return UV_OK;
case ERROR_FILE_NOT_FOUND: return UV_ENOENT;
case ERROR_INVALID_NAME: return UV_ENOENT;
case ERROR_MOD_NOT_FOUND: return UV_ENOENT;
case ERROR_PATH_NOT_FOUND: return UV_ENOENT;
case ERROR_ACCESS_DENIED: return UV_EPERM;
case ERROR_NOACCESS: return UV_EACCES;
......@@ -125,6 +127,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;
}
}
......
......@@ -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)) {
......@@ -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));
......
......@@ -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); \
......@@ -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_;
......@@ -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_;
......@@ -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);
}
......@@ -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);
......@@ -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, req->stat.st_atime);
break;
case UV_FS_SENDFILE:
fs__sendfile(req,
......@@ -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);
......@@ -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);
......@@ -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);
......
......@@ -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;
}
......
......@@ -860,8 +860,8 @@ static int duplicate_std_handle(uv_loop_t* loop, DWORD id, HANDLE* dup) {