diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2024-07-07 00:34:44 +0900 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2024-07-09 00:01:22 +0900 |
commit | 10477d95ec401213d5bded5ae3600ab0d2d5ed94 (patch) | |
tree | 00158b5dfb739ca4b91742a78281ea8d68f25daa /winsup/utils/passwd.c | |
parent | 462059da26b68fd0ec0c51b1fdf11fbba0b6fa2a (diff) | |
download | newlib-10477d95ec401213d5bded5ae3600ab0d2d5ed94.zip newlib-10477d95ec401213d5bded5ae3600ab0d2d5ed94.tar.gz newlib-10477d95ec401213d5bded5ae3600ab0d2d5ed94.tar.bz2 |
Cygwin: console: Fix race issue on allocating console simultaneously.
Previously, if two or more processes request to allocate a console at
the same time, the same device number could be accidentally allocated.
This patch fixes the issue by creating a named mutex (input_mutex) and
checking if GetLastError() is ERROR_ALREADY_EXIST or not to ensure
the unit number will be allocated in an atomic way. Thanks to this,
EnumWindow() is not necessary anymore to scan console units.
This also makes minor device numbers unique and console devices visible
across sessions. This disallows duplicated device number for different
sessions, so the MAX_CONS_DEV has been increased from 64 to 128.
Additionally, the console allocation and scanning will be faster as
a side effect of eliminating EnumWindows().
Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'winsup/utils/passwd.c')
0 files changed, 0 insertions, 0 deletions