Skip to content

Commit

Permalink
win, tty: fix crash on restarting with pending data
Browse files Browse the repository at this point in the history
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: nodejs/node#9690
PR-URL: #1158
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
  • Loading branch information
seishun authored and saghul committed Dec 6, 2016
1 parent f8d4805 commit 357b9a7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/win/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 357b9a7

Please sign in to comment.