console: allow one user at a time.

Fixes #15142.

Change-Id: I203cb62a6640fcd5f674eeaf4aa1145e1e831ca6
Reviewed-on: https://review.haiku-os.org/c/1566
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Jérôme Duval 2019-07-08 21:22:48 +02:00 committed by waddlesplash
parent 2f6dc2bb79
commit ed9a502a9a

View File

@ -78,6 +78,8 @@ static struct console_desc {
int32 api_version = B_CUR_DRIVER_API_VERSION;
static int32 sOpenMask;
static inline void
update_cursor(struct console_desc *console, int x, int y)
@ -659,6 +661,9 @@ _console_write(struct console_desc *console, const void *buffer, size_t length)
static status_t
console_open(const char *name, uint32 flags, void **cookie)
{
if (atomic_or(&sOpenMask, 1) == 1)
return B_BUSY;
*cookie = &sConsole;
status_t status = get_module(sConsole.module_name, (module_info **)&sConsole.module);
@ -677,6 +682,8 @@ console_freecookie(void *cookie)
sConsole.module = NULL;
}
atomic_and(&sOpenMask, ~1);
return B_OK;
}