win: fix race condition in uv__init_console() (#3973)

Co-authored-by: Arlie Davis <ardavis@microsoft.com>
Fixes: https://github.com/libuv/libuv/issues/3970
This commit is contained in:
sivadeilra 2023-04-29 03:59:56 -07:00 committed by GitHub
parent 932092e95d
commit c51522c08f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,14 +170,14 @@ void uv__console_init(void) {
0);
if (uv__tty_console_handle != INVALID_HANDLE_VALUE) {
CONSOLE_SCREEN_BUFFER_INFO sb_info;
QueueUserWorkItem(uv__tty_console_resize_message_loop_thread,
NULL,
WT_EXECUTELONGFUNCTION);
uv_mutex_init(&uv__tty_console_resize_mutex);
if (GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info)) {
uv__tty_console_width = sb_info.dwSize.X;
uv__tty_console_height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1;
}
QueueUserWorkItem(uv__tty_console_resize_message_loop_thread,
NULL,
WT_EXECUTELONGFUNCTION);
}
}
@ -2423,7 +2423,6 @@ static void uv__tty_console_signal_resize(void) {
height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1;
uv_mutex_lock(&uv__tty_console_resize_mutex);
assert(uv__tty_console_width != -1 && uv__tty_console_height != -1);
if (width != uv__tty_console_width || height != uv__tty_console_height) {
uv__tty_console_width = width;
uv__tty_console_height = height;