Skip to content

Commit

Permalink
Fix a bug where the stream would not close if no data was received
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Jun 3, 2014
1 parent deedd03 commit 0db0242
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/unix/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ int uv_pipe_link(uv_pipe_t *read, uv_pipe_t *write) {
uv__nonblock(fds[1], 1);
}

err = uv__stream_open((uv_stream_t*)read, fds[0], 0);
err = uv__stream_open((uv_stream_t*)read, fds[0], UV_STREAM_READABLE);
if (err) {
close(fds[0]);
close(fds[1]);
goto pipe_error;
}

err = uv__stream_open((uv_stream_t*)write, fds[1], 0);
err = uv__stream_open((uv_stream_t*)write, fds[1], UV_STREAM_WRITABLE);
if (err) {
uv_pipe_close_sync(read);
close(fds[0]);
Expand Down
6 changes: 3 additions & 3 deletions src/unix/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,10 +1209,10 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
* have to do anything. If the partial read flag is not set, we can't
* report the EOF yet because there is still data to read.
*/
if ((events & UV__POLLHUP) &&
(stream->flags & UV_STREAM_READING) &&
if ((events & UV__POLLHUP) && ((events == UV__POLLHUP) ||
((stream->flags & UV_STREAM_READING) &&
(stream->flags & UV_STREAM_READ_PARTIAL) &&
!(stream->flags & UV_STREAM_READ_EOF)) {
!(stream->flags & UV_STREAM_READ_EOF)))) {
uv_buf_t buf = { NULL, 0 };
uv__stream_eof(stream, &buf);
}
Expand Down

0 comments on commit 0db0242

Please sign in to comment.