win, tty: fix crash on restarting with pending data
When reading from tty is restarted while there is pending data, uv_tty_read_start calls uv_insert_pending_req instead of uv_tty_queue_read to avoid losing keypresses. But reading can be stopped and restarted multiple times before the req is handled, which caused an assertion error. Setting the UV_HANDLE_READ_PENDING flag prevents uv_insert_pending_req from being called again until the req is handled. Fixes: https://github.com/nodejs/node/issues/9690 PR-URL: https://github.com/libuv/libuv/pull/1158 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
f8d4805087
commit
357b9a7733
@ -1004,6 +1004,9 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb,
|
||||
if (handle->tty.rd.last_key_len > 0) {
|
||||
SET_REQ_SUCCESS(&handle->read_req);
|
||||
uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req);
|
||||
/* Make sure no attempt is made to insert it again until it's handled. */
|
||||
handle->flags |= UV_HANDLE_READ_PENDING;
|
||||
handle->reqs_pending++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user