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 674213 - tests: Fix race conditions in mainloop/invoke test
tests: Fix race conditions in mainloop/invoke test
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-04-16 17:57 UTC by Colin Walters
Modified: 2012-04-16 18:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests: Fix race conditions in mainloop/invoke test (1.64 KB, patch)
2012-04-16 17:57 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2012-04-16 17:57:00 UTC
1) The test was using GCond incorrectly (it always needs a
   state variable)
2) The state assertion was racing with the thread; just swap
   the lines for the assert with the invoke.  All we're really
   trying to test here is that the invoke runs by the time the
   thread is gone.
Comment 1 Colin Walters 2012-04-16 17:57:02 UTC
Created attachment 212163 [details] [review]
tests: Fix race conditions in mainloop/invoke test
Comment 2 Dan Winship 2012-04-16 18:05:38 UTC
Comment on attachment 212163 [details] [review]
tests: Fix race conditions in mainloop/invoke test

>2) The state assertion was racing with the thread; just swap
>   the lines for the assert with the invoke.  All we're really
>   trying to test here is that the invoke runs by the time the
>   thread is gone.

I think the goal was "make sure that g_main_context_invoke() didn't invoke func() directly", but func() already has an assertion that it's being run in the expected thread, so we're ok.

There's already an assertion that count==2 before we create the context though, and no reason to imagine it would have changed in the interim, so you could just remove that check entirely.

>+static gboolean cond_b;

a real name would be nice ("thread_ready"?)

ok to commit however
Comment 3 Colin Walters 2012-04-16 18:17:08 UTC
Fixed for both comments.

Attachment 212163 [details] pushed as 3ac2930 - tests: Fix race conditions in mainloop/invoke test