win, tcp: avoid starving the loop
Limit the time a TCP read callback can be called on a single loop
iteration to 32.
Ref: 738b31eb3a
Fixes: https://github.com/libuv/libuv/issues/2027
PR-URL: https://github.com/libuv/libuv/pull/2049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
6dd44caa35
commit
8a647d436f
@ -945,6 +945,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
uv_req_t* req) {
|
||||
DWORD bytes, flags, err;
|
||||
uv_buf_t buf;
|
||||
int count;
|
||||
|
||||
assert(handle->type == UV_TCP);
|
||||
|
||||
@ -999,7 +1000,8 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
}
|
||||
|
||||
/* Do nonblocking reads until the buffer is empty */
|
||||
while (handle->flags & UV_HANDLE_READING) {
|
||||
count = 32;
|
||||
while ((handle->flags & UV_HANDLE_READING) && (count-- > 0)) {
|
||||
buf = uv_buf_init(NULL, 0);
|
||||
handle->alloc_cb((uv_handle_t*) handle, 65536, &buf);
|
||||
if (buf.base == NULL || buf.len == 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user