Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
unix: avoid unnecessary read() syscall
  • Loading branch information
bnoordhuis committed Oct 7, 2011
1 parent 0364809 commit 5816f2d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/unix/stream.c
Expand Up @@ -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);
Expand Down Expand Up @@ -600,6 +601,11 @@ static void uv__read(uv_stream_t* stream) {
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;
}
}
}
}
Expand Down

0 comments on commit 5816f2d

Please sign in to comment.