diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2022-03-02 16:00:31 +0900 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2022-03-02 19:20:48 +0900 |
commit | 5f4e7b0368940682706916fec6d22befd4e82703 (patch) | |
tree | 7ac1a7d4c6c0f5d64d43cecddc70b88dcd5adbaf /winsup/cygwin/select.cc | |
parent | 42e23c5ad2641945097699e989427f0f88c7074b (diff) | |
download | newlib-5f4e7b0368940682706916fec6d22befd4e82703.zip newlib-5f4e7b0368940682706916fec6d22befd4e82703.tar.gz newlib-5f4e7b0368940682706916fec6d22befd4e82703.tar.bz2 |
Cygwin: console, pty: Revamp the acquire/release_attach_mutex timing.
- This patch revises the acquiring/releasing timing for attach_mutex
to make the period in which it is being acquired shorter. Further,
acquiring/releasing are added to where they are missing but needed.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r-- | winsup/cygwin/select.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 80a9527..64e35cf 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -1095,8 +1095,6 @@ fhandler_fifo::select_except (select_stuff *ss) return s; } -extern DWORD mutex_timeout; /* defined in fhandler_termios.cc */ - static int peek_console (select_record *me, bool) { @@ -1123,7 +1121,6 @@ peek_console (select_record *me, bool) set_handle_or_return_if_not_open (h, me); fh->acquire_input_mutex (mutex_timeout); - acquire_attach_mutex (mutex_timeout); while (!fh->input_ready && !fh->get_cons_readahead_valid ()) { if (fh->bg_check (SIGTTIN, true) <= bg_eof) @@ -1132,8 +1129,14 @@ peek_console (select_record *me, bool) fh->release_input_mutex (); return me->read_ready = true; } - else if (!PeekConsoleInputW (h, &irec, 1, &events_read) || !events_read) - break; + else + { + acquire_attach_mutex (mutex_timeout); + BOOL r = PeekConsoleInputW (h, &irec, 1, &events_read); + release_attach_mutex (); + if (!r || !events_read) + break; + } if (fhandler_console::input_winch == fh->process_input_message () && global_sigs[SIGWINCH].sa_handler != SIG_IGN && global_sigs[SIGWINCH].sa_handler != SIG_DFL) @@ -1144,7 +1147,6 @@ peek_console (select_record *me, bool) return -1; } } - release_attach_mutex (); fh->release_input_mutex (); if (fh->input_ready || fh->get_cons_readahead_valid ()) return me->read_ready = true; |