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 692618 - Use g_timeout_add_seconds
Use g_timeout_add_seconds
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-01-27 06:11 UTC by B.Prathibha
Modified: 2013-02-03 15:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Reduce wakeups (11.13 KB, patch)
2013-01-27 06:14 UTC, B.Prathibha
needs-work Details | Review
Reduce wakeups (3.02 KB, patch)
2013-01-28 01:06 UTC, B.Prathibha
none Details | Review

Comment 1 B.Prathibha 2013-01-27 06:14:36 UTC
Created attachment 234511 [details] [review]
Reduce wakeups

Use g_timeout_add_seconds instead of g_timeout_add wherever possible.
Comment 2 Dan Winship 2013-01-27 13:46:32 UTC
Comment on attachment 234511 [details] [review]
Reduce wakeups

Please read the comments on that GnomeGoal; g_timeout_add_seconds() is irrelevant for test programs or timeouts that only trigger once (though in some cases it's harmless and makes the code clearer), and it's explicitly wrong for "short" timeouts, since it may trigger in slightly more or less than the declared timeout time, resulting in different behavior than you intended. (Eg, switching the test program timeouts to g_timeout_add_seconds() may cause them to time out sooner, resulting in the test failing when it otherwise would have succeeded.)
Comment 3 B.Prathibha 2013-01-28 01:06:22 UTC
Created attachment 234572 [details] [review]
Reduce wakeups

Use g_timeout_add_seconds instead of g_timeout_add wherever possible.
Comment 4 B.Prathibha 2013-01-28 01:12:05 UTC
Comment on attachment 234572 [details] [review]
Reduce wakeups

>--- a/gio/tests/gdbus-connection.c
>+++ b/gio/tests/gdbus-connection.c

>@@ -234,7 +234,7 @@ test_connection_life_cycle (void)
>-  quit_mainloop_id = g_timeout_add (30000, test_connection_quit_mainloop, (gpointer) &quit_mainloop_fired);
>+  quit_mainloop_id = g_timeout_add_seconds (30, test_connection_quit_mainloop, (gpointer) &quit_mainloop_fired);

>@@ -693,7 +693,7 @@ test_connection_signals (void)
>-  quit_mainloop_id = g_timeout_add (30000, test_connection_quit_mainloop, &quit_mainloop_fired);
>+  quit_mainloop_id = g_timeout_add_seconds (30, test_connection_quit_mainloop, &quit_mainloop_fired);

>--- a/gio/tests/gdbus-tests.c
>+++ b/gio/tests/gdbus-tests.c

>@@ -68,7 +68,7 @@ _g_assert_property_notify_run (gpointer     object,
>                                  G_CALLBACK (on_property_notify),
>                                  &data);
>   g_free (s);
>-  timeout_id = g_timeout_add (30 * 1000,
>+  timeout_id = g_timeout_add_seconds (30,
>                               on_property_notify_timeout,
>                               &data);

>@@ -117,7 +117,7 @@ _g_assert_signal_received_run (gpointer     object,
>                                          signal_name,
>                                          G_CALLBACK (on_signal_received),
>                                          &data);
>-  timeout_id = g_timeout_add (30 * 1000,
>+  timeout_id = g_timeout_add_seconds (30,
>                               on_signal_received_timeout,
>                               &data);

>diff --git a/tests/child-test.c b/tests/child-test.c
>index 9ebc202..ec36b24 100644
>--- a/tests/child-test.c
>+++ b/tests/child-test.c

>@@ -176,7 +176,7 @@ main (int argc, char *argv[])

>-  g_timeout_add (30000, quit_loop, main_loop);
>+  g_timeout_add_seconds (30, quit_loop, main_loop);
> 

In all these, the timeout is more than 1 sec and it is recurring.
Comment 5 Matthias Clasen 2013-02-03 15:21:30 UTC
But all of these are in gio/tests/ - ie they are irrelevant to the operation of installed software. Anyway, i've taken the ones that are clearly just 'don't let the tests wait forever'.