Browse Source

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.
suites/experimental
Kenny Levinsen 2 years ago
parent
commit
be45c480ec
  1. 18
      common/terminal.c
  2. 2
      include/seat.h
  3. 3
      include/terminal.h
  4. 20
      seatd/seat.c
  5. 2
      seatd/server.c

18
common/terminal.c

@ -199,7 +199,7 @@ int terminal_set_process_switching(int fd, bool enable) {
}
int terminal_switch_vt(int fd, int vt) {
log_debugf("switching to vt %d", vt);
log_debugf("switching to VT %d", vt);
if (ioctl(fd, VT_ACTIVATE, vt) == -1) {
log_errorf("could not activate VT: %s", strerror(errno));
return -1;
@ -208,10 +208,20 @@ int terminal_switch_vt(int fd, int vt) {
return 0;
}
int terminal_ack_switch(int fd) {
log_debug("acking vt switch");
int terminal_ack_release(int fd) {
log_debug("acking VT release");
if (ioctl(fd, VT_RELDISP, 1) == -1) {
log_errorf("could not ack VT release: %s", strerror(errno));
return -1;
}
return 0;
}
int terminal_ack_acquire(int fd) {
log_debug("acking VT acquire");
if (ioctl(fd, VT_RELDISP, VT_ACKACQ) == -1) {
log_errorf("could not ack VT switch: %s", strerror(errno));
log_errorf("could not ack VT acquire: %s", strerror(errno));
return -1;
}

2
include/seat.h

@ -53,6 +53,6 @@ struct seat_device *seat_find_device(struct client *client, int device_id);
int seat_set_next_session(struct client *client, int session);
int seat_vt_activate(struct seat *seat);
int seat_prepare_vt_switch(struct seat *seat);
int seat_vt_release(struct seat *seat);
#endif

3
include/terminal.h

@ -8,7 +8,8 @@ int terminal_open(int vt);
int terminal_set_process_switching(int fd, bool enable);
int terminal_current_vt(int fd);
int terminal_switch_vt(int fd, int vt);
int terminal_ack_switch(int fd);
int terminal_ack_release(int fd);
int terminal_ack_acquire(int fd);
int terminal_set_keyboard(int fd, bool enable);
int terminal_set_graphics(int fd, bool enable);

20
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;
}

2
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;
}

Loading…
Cancel
Save