From be45c480ec0792c7dfb97e39b4f5369b75593ae8 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Tue, 22 Sep 2020 01:00:18 +0200 Subject: terminal: Ack both release and acquire Linux only requires acking release and ignores ack of acquire, but FreeBSD is more stringent and will patiently wait for both to be acked. Implement proper acking for both events. --- seatd/seat.c | 20 ++++++++++++-------- seatd/server.c | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'seatd') diff --git a/seatd/seat.c b/seatd/seat.c index 16935cf..1ce44d0 100644 --- a/seatd/seat.c +++ b/seatd/seat.c @@ -99,13 +99,17 @@ static int vt_switch(struct seat *seat, int vt) { return 0; } -static int vt_ack(struct seat *seat) { +static int vt_ack(struct seat *seat, bool release) { int tty0fd = terminal_open(seat->cur_vt); if (tty0fd == -1) { log_errorf("unable to open tty0: %s", strerror(errno)); return -1; } - terminal_ack_switch(tty0fd); + if (release) { + terminal_ack_release(tty0fd); + } else { + terminal_ack_acquire(tty0fd); + } close(tty0fd); return 0; } @@ -610,29 +614,29 @@ int seat_vt_activate(struct seat *seat) { log_debug("VT activation on non VT-bound seat, ignoring"); return -1; } - - log_debug("switching session from VT activation"); seat_update_vt(seat); + log_debug("activating VT"); + vt_ack(seat, false); if (seat->active_client == NULL) { seat_activate(seat); } return 0; } -int seat_prepare_vt_switch(struct seat *seat) { +int seat_vt_release(struct seat *seat) { assert(seat); if (!seat->vt_bound) { - log_debug("VT switch request on non VT-bound seat, ignoring"); + log_debug("VT release request on non VT-bound seat, ignoring"); return -1; } seat_update_vt(seat); - log_debug("acking VT switch"); + log_debug("releasing VT"); if (seat->active_client != NULL) { seat_disable_client(seat->active_client); } - vt_ack(seat); + vt_ack(seat, true); seat->cur_vt = -1; return 0; } diff --git a/seatd/server.c b/seatd/server.c index 90aa610..acb366e 100644 --- a/seatd/server.c +++ b/seatd/server.c @@ -97,7 +97,7 @@ static int server_handle_vt_rel(int signal, void *data) { return -1; } - seat_prepare_vt_switch(seat); + seat_vt_release(seat); return 0; } -- cgit v1.2.3