diff --git a/deps/uv/Makefile b/deps/uv/Makefile index 884f514bf2..cf1e7880bf 100644 --- a/deps/uv/Makefile +++ b/deps/uv/Makefile @@ -80,7 +80,7 @@ endif TESTS=test/blackhole-server.c test/echo-server.c test/test-*.c BENCHMARKS=test/blackhole-server.c test/echo-server.c test/dns-server.c test/benchmark-*.c -all: uv.a test/run-tests$(E) test/run-benchmarks$(E) +all: uv.a $(CARES_OBJS): %.o: %.c $(CC) -o $*.o -c $(CFLAGS) $(CPPFLAGS) $< -DHAVE_CONFIG_H diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c index 06af65d5b8..c43660d800 100644 --- a/deps/uv/src/unix/process.c +++ b/deps/uv/src/unix/process.c @@ -110,6 +110,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, #endif int status; pid_t pid; + int flags; uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS); loop->counters.process_init++; @@ -255,8 +256,9 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, assert(stdin_pipe[0] >= 0); uv__close(stdin_pipe[0]); uv__nonblock(stdin_pipe[1], 1); + flags = UV_WRITABLE | (options.stdin_stream->ipc ? UV_READABLE : 0); uv__stream_open((uv_stream_t*)options.stdin_stream, stdin_pipe[1], - UV_WRITABLE); + flags); } if (stdout_pipe[0] >= 0) { @@ -264,8 +266,9 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, assert(stdout_pipe[1] >= 0); uv__close(stdout_pipe[1]); uv__nonblock(stdout_pipe[0], 1); + flags = UV_READABLE | (options.stdout_stream->ipc ? UV_WRITABLE : 0); uv__stream_open((uv_stream_t*)options.stdout_stream, stdout_pipe[0], - UV_READABLE); + flags); } if (stderr_pipe[0] >= 0) { @@ -273,8 +276,9 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, assert(stderr_pipe[1] >= 0); uv__close(stderr_pipe[1]); uv__nonblock(stderr_pipe[0], 1); + flags = UV_READABLE | (options.stderr_stream->ipc ? UV_WRITABLE : 0); uv__stream_open((uv_stream_t*)options.stderr_stream, stderr_pipe[0], - UV_READABLE); + flags); } return 0; diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 0268158252..a68d7a964a 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -563,6 +563,7 @@ static void uv__read(uv_stream_t* stream) { return; } else { /* Successful read */ + size_t buflen = buf.len; if (stream->read_cb) { stream->read_cb(stream, nread, buf); @@ -599,6 +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; + } } } } @@ -907,14 +913,11 @@ int uv_read2_start(uv_stream_t* stream, uv_alloc_cb alloc_cb, int uv_read_stop(uv_stream_t* stream) { - uv_tcp_t* tcp = (uv_tcp_t*)stream; - - ((uv_handle_t*)tcp)->flags &= ~UV_READING; - - ev_io_stop(tcp->loop->ev, &tcp->read_watcher); - tcp->read_cb = NULL; - tcp->read2_cb = NULL; - tcp->alloc_cb = NULL; + ev_io_stop(stream->loop->ev, &stream->read_watcher); + stream->flags &= ~UV_READING; + stream->read_cb = NULL; + stream->read2_cb = NULL; + stream->alloc_cb = NULL; return 0; } diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index d5e7e2915a..73939e2bfd 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -1163,13 +1163,21 @@ TEST_IMPL(fs_symlink) { TEST_IMPL(fs_utime) { utime_check_t checkme; - const char* path = "."; + const char* path = "test_file"; double atime; double mtime; uv_fs_t req; int r; + /* Setup. */ loop = uv_default_loop(); + unlink(path); + r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, + S_IWRITE | S_IREAD, NULL); + ASSERT(r != -1); + ASSERT(req.result != -1); + uv_fs_req_cleanup(&req); + close(r); atime = mtime = 400497753; /* 1982-09-10 11:22:33 */ @@ -1196,24 +1204,35 @@ TEST_IMPL(fs_utime) { uv_run(loop); ASSERT(utime_cb_count == 1); + /* Cleanup. */ + unlink(path); + return 0; } TEST_IMPL(fs_futime) { utime_check_t checkme; - const char* path = "."; + const char* path = "test_file"; double atime; double mtime; uv_file file; uv_fs_t req; int r; + /* Setup. */ loop = uv_default_loop(); + unlink(path); + r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, + S_IWRITE | S_IREAD, NULL); + ASSERT(r != -1); + ASSERT(req.result != -1); + uv_fs_req_cleanup(&req); + close(r); atime = mtime = 400497753; /* 1982-09-10 11:22:33 */ - r = uv_fs_open(loop, &req, path, O_RDONLY, 0, NULL); + r = uv_fs_open(loop, &req, path, O_RDWR, 0, NULL); ASSERT(r != -1); ASSERT(req.result != -1); file = req.result; /* FIXME probably not how it's supposed to be used */ @@ -1243,6 +1262,9 @@ TEST_IMPL(fs_futime) { uv_run(loop); ASSERT(futime_cb_count == 1); + /* Cleanup. */ + unlink(path); + return 0; }