From 6c95669d23c27bad29a47a70ff2dec7136f6cdf6 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 10 Mar 2012 17:51:33 +0000 Subject: [PATCH] * dtable.cc (fh_alloc): Treat pc.dev as unsigned. * fhandler_console.cc (fhandler_console::set_unit): Use lock always to avoid races between competing cygwin processes running on the console. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/dtable.cc | 2 +- winsup/cygwin/fhandler_console.cc | 6 ++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9043b7d93..fcc1d11f8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2012-03-10 Christopher Faylor + + * dtable.cc (fh_alloc): Treat pc.dev as unsigned. + * fhandler_console.cc (fhandler_console::set_unit): Use lock always to + avoid races between competing cygwin processes running on the console. + 2012-03-09 Corinna Vinschen * hookapi.cc (find_first_notloaded_dll): Fix a compiler warning. diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 612506e0c..7f414accc 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -478,7 +478,7 @@ fh_alloc (path_conv& pc) fh = cnew (fhandler_console, pc.dev); break; default: - switch ((int) pc.dev) + switch ((DWORD) pc.dev) { case FH_CONSOLE: case FH_CONIN: diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 32454511a..a3553a728 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -134,6 +134,7 @@ fhandler_console::set_unit () { bool created; fh_devices devset; + lock_ttys here; if (shared_console_info) { fh_devices this_unit = dev (); @@ -152,10 +153,7 @@ fhandler_console::set_unit () shared_console_info = open_shared_console (me, cygheap->console_h, created); ProtectHandleINH (cygheap->console_h); if (created) - { - lock_ttys here; - shared_console_info->tty_min_state.setntty (DEV_CONS_MAJOR, console_unit (me)); - } + shared_console_info->tty_min_state.setntty (DEV_CONS_MAJOR, console_unit (me)); devset = (fh_devices) shared_console_info->tty_min_state.getntty (); }