Should async methods notify first, before completing tasks?
According to https://gitlab.freedesktop.org/dbus/dbus/-/issues/179, message order is guaranteed.
I ran into this issue in the following pattern:
static void
update_ring_state (CallsRinger *self)
{
LfbEventState event_state;
event_state = lfb_event_get_state (self->event);
switch (event_state) {
case LFB_EVENT_STATE_ENDED:
set_ring_state (self, CALLS_RING_STATE_INACTIVE);
break;
case LFB_EVENT_STATE_RUNNING:
set_ring_state (self, CALLS_RING_STATE_ACTIVE);
[...]
}
static void
on_event_triggered (LfbEvent *event,
GAsyncResult *res,
CallsRinger *self)
{
g_autoptr (GError) err = NULL;
gboolean ok;
g_return_if_fail (LFB_IS_EVENT (event));
ok = lfb_event_trigger_feedback_finish (event, res, &err);
[...]
update_ring_state (self);
}
which will not have updated LfbEventState
because the state is updated after the GTask
completes (see https://source.puri.sm/Librem5/feedbackd/-/blob/master/libfeedback/lfb-event.c#L163-172):
if (!success) {
g_task_return_error (task, g_steal_pointer (&err));
state = LFB_EVENT_STATE_ERRORED;
} else {
g_task_return_boolean (task, TRUE);
state = LFB_EVENT_STATE_RUNNING;
_lfb_active_add_id (self->id);
}
lfb_event_set_state (self, state);