From 60c370d4ecdd0645738a6532bed1c9647e2224cb Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Thu, 2 Sep 2021 23:03:20 +0200 Subject: seat: Allow new clients when active is pending ack New clients could only be added to a VT bound seat if there were no "active" client, regardless of its actual state. This meant that if one switched from an "active" VT to an "inactive" VT, the seat would be blocked while the "active" client was in CLIENT_PENDING_DISABLE, causing new clients to possibly fail should the old client take its time with the ack. Instead, allow new clients to also be added if there is an active client whose state is CLIENT_PENDING_DISABLE, and there is no client with the new VT as its session ID. --- seatd/seat.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'seatd') diff --git a/seatd/seat.c b/seatd/seat.c index 842928e..354273f 100644 --- a/seatd/seat.c +++ b/seatd/seat.c @@ -129,7 +129,8 @@ int seat_add_client(struct seat *seat, struct client *client) { return -1; } - if (seat->vt_bound && seat->active_client != NULL) { + if (seat->vt_bound && seat->active_client != NULL && + seat->active_client->state != CLIENT_PENDING_DISABLE) { log_error("Could not add client: seat is VT-bound and has an active client"); errno = EBUSY; return -1; @@ -148,6 +149,17 @@ int seat_add_client(struct seat *seat, struct client *client) { errno = EINVAL; return -1; } + if (seat->active_client != NULL) { + for (struct linked_list *elem = seat->clients.next; elem != &seat->clients; + elem = elem->next) { + struct client *client = (struct client *)elem; + if (client->session == seat->cur_vt) { + log_error("Could not add client: seat is VT-bound and already has pending client"); + errno = EBUSY; + return -1; + } + } + } client->session = seat->cur_vt; } else { client->session = seat->session_cnt++; -- cgit v1.2.3