Skip to content

Commit 0db0242

Browse files
committed
Fix a bug where the stream would not close if no data was received
1 parent deedd03 commit 0db0242

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/unix/pipe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ int uv_pipe_link(uv_pipe_t *read, uv_pipe_t *write) {
129129
uv__nonblock(fds[1], 1);
130130
}
131131

132-
err = uv__stream_open((uv_stream_t*)read, fds[0], 0);
132+
err = uv__stream_open((uv_stream_t*)read, fds[0], UV_STREAM_READABLE);
133133
if (err) {
134134
close(fds[0]);
135135
close(fds[1]);
136136
goto pipe_error;
137137
}
138138

139-
err = uv__stream_open((uv_stream_t*)write, fds[1], 0);
139+
err = uv__stream_open((uv_stream_t*)write, fds[1], UV_STREAM_WRITABLE);
140140
if (err) {
141141
uv_pipe_close_sync(read);
142142
close(fds[0]);

src/unix/stream.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,10 +1209,10 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
12091209
* have to do anything. If the partial read flag is not set, we can't
12101210
* report the EOF yet because there is still data to read.
12111211
*/
1212-
if ((events & UV__POLLHUP) &&
1213-
(stream->flags & UV_STREAM_READING) &&
1212+
if ((events & UV__POLLHUP) && ((events == UV__POLLHUP) ||
1213+
((stream->flags & UV_STREAM_READING) &&
12141214
(stream->flags & UV_STREAM_READ_PARTIAL) &&
1215-
!(stream->flags & UV_STREAM_READ_EOF)) {
1215+
!(stream->flags & UV_STREAM_READ_EOF)))) {
12161216
uv_buf_t buf = { NULL, 0 };
12171217
uv__stream_eof(stream, &buf);
12181218
}

0 commit comments

Comments
 (0)