After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750206 - wrong if condition of g_wake_up_acknowledge in g_main_context_check()
wrong if condition of g_wake_up_acknowledge in g_main_context_check()
Status: RESOLVED DUPLICATE of bug 761102
Product: glib
Classification: Platform
Component: mainloop
2.45.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-06-01 09:21 UTC by sole-hubin
Modified: 2016-04-21 12:19 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description sole-hubin 2015-06-01 09:21:06 UTC
In g_main_context_check(param1, param2, GPollFD *fds, param4), the third param fds points to the results of poll(), where revents are modified by poll(). 

Near line 3599, it comes:
    if (context->wake_up_rec.revents)
        g_wakeup_acknowledge (context->wakeup);
before near line 3613:
while (pollrec && i < n_fds) ... // write revents back to pollrecs.

If a wakeup exists, it will modify directly the revents in fds in the poll(), rather than the revents of pollrec. As a result, wake_up_rec.revents (a pollrec) stays still 0 filled, g_wakeup_acknowledge would not be called.

The whole system can still run, though g_wakeup_acknowledge isn't called in time(I mean exactly after the wakeup exists), the "while" loop near line 3613 will then modify wake_up_rec(a pollrec), and the poll() during next g_main_context_iteration will not block as the fd used for wakeup is still readable, as wake_up_rec.revents is not 0 filled during the second g_main_context_check, g_wakeup_acknowledge will be called and the whole story of wakeup ends here. However, as we can see, redundant one loop of g_main_context_iteration reduce performance.

In my opinion, the problem can be solved by either:
1. remove if condition of g_wakeup_acknowledge, just like what version 2.28.8 does;
or:
2. move if condition and g_wakeup_acknowledge to after the "while" loop near line 3613.
Comment 1 Tim Janik 2016-04-21 12:19:59 UTC
Thanks for taking the time to report this and an accurate analysis.
Bug #761102 has a patch for this.

*** This bug has been marked as a duplicate of bug 761102 ***