aboutsummaryrefslogtreecommitdiff
path: root/libseat
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-09-19 21:33:55 +0200
committerKenny Levinsen <kl@kl.wtf>2020-09-22 01:01:46 +0200
commit4c22c7b00414ad93809adc619062ca89345aeaa1 (patch)
treee84eac4ef289e6b5cdef06f7b772f2c157dea1a7 /libseat
parent9c6682a8311c3d05a11ffa365bd46a561da4289e (diff)
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.
Diffstat (limited to 'libseat')
-rw-r--r--libseat/backend/seatd.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libseat/backend/seatd.c b/libseat/backend/seatd.c
index 0b8064d..2f7b384 100644
--- a/libseat/backend/seatd.c
+++ b/libseat/backend/seatd.c
@@ -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;
}