Created attachment 76562 [details] [review] When sleeping in the example provider, deal with immediate cancellation. When sleeping in the example provider, deal with immediate cancellation. * service/realm-example-provider.c (on_discover_sleep_done): Always complete in idle, as expected. * service/realm-usleep-async.c (realm_usleep_async): Check for immediate cancellation, to avoid calling on_sleep_async_cancelled before we are done initializing. Also, change ownership handling to be more straightforward and to allow both timeout and cancelling to occur at the same time.
Comment on attachment 76562 [details] [review] When sleeping in the example provider, deal with immediate cancellation. Review of attachment 76562 [details] [review]: ----------------------------------------------------------------- ::: service/realm-example-provider.c @@ +99,4 @@ > if (!realm_usleep_finish (res, &error)) > g_simple_async_result_take_error (async, error); > > + g_simple_async_result_complete_in_idle (async); Is this because realm_usleep_async() sometimes calls its GAsyncResultReady callback immediately? If so, then its breaking the gio async style guarantees (a GAsyncReadyCallback should only ever be called after returning to the main loop) and the bug should be fixed in realm_usleep_async() and not worked around here.
(In reply to comment #1) > > + g_simple_async_result_complete_in_idle (async); > > Is this because realm_usleep_async() sometimes calls its GAsyncResultReady > callback immediately? Yes. > If so, then its breaking the gio async style > guarantees (a GAsyncReadyCallback should only ever be called after returning > to the main loop) and the bug should be fixed in realm_usleep_async() and > not worked around here. Aha! I didn't know about this guarantee. Would you say that realm_usleep_async now does the right thing, with this patch?
This doesn't apply to git master, realm-usleep-async.c has lots of conflicts. Does it depend on another patch?
(In reply to comment #3) > This doesn't apply to git master, realm-usleep-async.c has lots of > conflicts. Does it depend on another patch? No, I think it was just some minor formatting differences.
Created attachment 77992 [details] [review] When sleeping in the example provider, deal with immediate cancellation.
Attachment 77992 [details] pushed as 36b1f25 - When sleeping in the example provider, deal with immediate cancellation.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.