unix: avoid unnecessary read() syscall

This commit is contained in:
Ben Noordhuis 2011-10-07 02:08:15 +02:00
parent 0364809fb5
commit 5816f2d21c

View File

@ -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);
@ -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;
}
}
}
}