libseat: Dispatch all non-bg events on IPC call

Dispatch on IPC call only dispatched until the first message was
successfully processed. This could lead to premature dispatch
termination if a background event was received during an IPC call.

Instead, continue dispatching until a non-bg opcode is reported or an
error is received.
This commit is contained in:
Kenny Levinsen 2020-09-19 21:33:55 +02:00
parent 9c6682a831
commit 4c22c7b004

View file

@ -288,16 +288,20 @@ static int dispatch(struct backend_seatd *backend) {
if (conn_flush(backend) == -1) {
return -1;
}
int opcode = 0, res = 0;
while ((res = dispatch_pending(backend, &opcode)) == 0 && opcode == 0) {
while (true) {
int opcode = 0;
if (dispatch_pending(backend, &opcode) == -1) {
log_errorf("Could not dispatch pending messages: %s", strerror(errno));
return -1;
}
if (opcode != 0) {
break;
}
if (poll_connection(backend, -1) == -1) {
log_errorf("Could not poll connection: %s", strerror(errno));
return -1;
}
}
if (res == -1) {
return -1;
}
return 0;
}