From b901e2620cdf79534730bbdff5b3d41f2fccb6d6 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Tue, 23 Oct 2018 16:18:34 +0200 Subject: [PATCH] win, tty: remove zero-size read callbacks In some situations console read callback would return 0 bytes read. According to documentation this means EAGAIN or EWOULDBLOCK, which is not the case in any of the situations that currently happen. This removes those zero-size callbacks. Fixes: https://github.com/libuv/libuv/issues/2012 PR-URL: https://github.com/libuv/libuv/pull/2014 Reviewed-By: Colin Ihrig --- src/win/tty.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/win/tty.c b/src/win/tty.c index 32ccf74c..398288ec 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -941,20 +941,15 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle, handle->read_cb((uv_stream_t*) handle, uv_translate_sys_error(GET_REQ_ERROR(req)), &buf); - } else { - /* The read was cancelled, or whatever we don't care */ - handle->read_cb((uv_stream_t*) handle, 0, &buf); } - } else { - if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { + if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING) && + req->u.io.overlapped.InternalHigh != 0) { /* Read successful. TODO: read unicode, convert to utf-8 */ DWORD bytes = req->u.io.overlapped.InternalHigh; handle->read_cb((uv_stream_t*) handle, bytes, &buf); - } else { - handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; - handle->read_cb((uv_stream_t*) handle, 0, &buf); } + handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; } /* Wait for more input events. */