GNOME Bugzilla – Bug 692983
GMainContext will dispatch non-ready sources if they used to be ready
Last modified: 2018-05-24 15:01:11 UTC
See the failing testcase and commit log message.
Created attachment 234950 [details] [review] mainloop: test non-ready source being dispatched The way GMainContext is currently setup is that any source, once marked 'ready', must be dispatched, even if it is not dispatched during this iteration and no longer ready on the next iteration (because something cancelled it). A source for a GCancellable that gets reset would be subject to this problem, for example, but we put the testcase in glib/ so we use a toy GSource to demonstrate.
So, we could just clear G_SOURCE_READY on everything either after dispatch or at the start of prepare. The question is, is there any reasonable code that would break if we did this? I don't think there is.
Created attachment 236278 [details] [review] gmain: mark undispatched sources as unready again GMainContext was assuming that once a source became ready, that it would remain ready until it got dispatched (even if that wasn't until a later iteration), but this is not always true. (Eg, a GCancellable source would no longer be ready if its cancellable was reset.) Change it to clear the ready flag on all undispatched sources at the end of the iteration, so they will be checked again on the next iteration.
(In reply to comment #2) > So, we could just clear G_SOURCE_READY on everything either after dispatch or > at the start of prepare. The question is, is there any reasonable code that > would break if we did this? I don't think there is. I guess we've got that fancy "make check"-running bot now...
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/666.