libseat/seatd: Return executed events

Dispatch needs to report if something has happened, which includes
events executed from the queue as these could have lead to additional
dispatch and queuing.
This commit is contained in:
Kenny Levinsen 2021-07-08 23:41:09 +02:00
parent 2204db5531
commit 7a6d12ff7a

View file

@ -206,10 +206,11 @@ static int queue_event(struct backend_seatd *backend, int opcode) {
return 0; return 0;
} }
static void execute_events(struct backend_seatd *backend) { static int execute_events(struct backend_seatd *backend) {
struct linked_list list; struct linked_list list;
linked_list_init(&list); linked_list_init(&list);
linked_list_take(&list, &backend->pending_events); linked_list_take(&list, &backend->pending_events);
int executed = 0;
while (!linked_list_empty(&list)) { while (!linked_list_empty(&list)) {
struct pending_event *ev = (struct pending_event *)list.next; struct pending_event *ev = (struct pending_event *)list.next;
int opcode = ev->opcode; int opcode = ev->opcode;
@ -231,7 +232,9 @@ static void execute_events(struct backend_seatd *backend) {
log_errorf("Invalid opcode: %d", opcode); log_errorf("Invalid opcode: %d", opcode);
abort(); abort();
} }
executed++;
} }
return executed;
} }
static int dispatch_pending(struct backend_seatd *backend, int *opcode) { static int dispatch_pending(struct backend_seatd *backend, int *opcode) {
@ -341,7 +344,7 @@ static int dispatch_background(struct libseat *base, int timeout) {
return -1; return -1;
} }
execute_events(backend); dispatched += execute_events(backend);
return dispatched; return dispatched;
} }