From 4c22c7b00414ad93809adc619062ca89345aeaa1 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 19 Sep 2020 21:33:55 +0200 Subject: 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. --- libseat/backend/seatd.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'libseat') 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; } -- cgit v1.2.3