sync done event shouldn't be sent until EIS implementation has processed previous events
If I am reading the code correctly, when a sync
message is received from the client, brei_dispatch()
will (indirectly) call client_msg_sync
, which then immediately calls eis_callback_event_done
to send the done event. The problem is that at this point, there may be earlier messages that the EIS implementation hasn't seen or processed yet, leading to the done message being queued out of order.
Instead, client_msg_sync
should add an event to the event queue, which could later be handled by eis_get_event()
. Something like this, maybe?
_public_ struct eis_event*
eis_get_event(struct eis *eis)
{
while (!list_empty(&eis->event_queue)) {
struct eis_event *e = list_first_entry(&eis->event_queue, e, link);
list_remove(&e->link);
// Might want to use some other indicator to avoid adding the
// internally-handled sync event to the public enum.
if (e->type == EIS_EVENT_SYNC) {
// TODO: Handle errors
int rc = eis_callback_event_done(e->sync.callback, 0);
eis_callback_unref(e->sync.callback);
ei_event_unref(e);
} else {
return e;
}
}
return NULL;
}
That way, the done callback would only be queued after the EIS implementation has retrieved (and presumably processed) all preceding events.