~kennylevinsen/seatd

60c370d4ecdd0645738a6532bed1c9647e2224cb — Kenny Levinsen 13 days ago 29a6832
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.
1 files changed, 13 insertions(+), 1 deletions(-)

M seatd/seat.c
M seatd/seat.c => seatd/seat.c +13 -1
@@ 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++;