mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 16:26:17 +01:00
Merge branch 'issue-2659' into 'main'
Fix /maincontext/timeout-once randomly fails Closes #2659 See merge request GNOME/glib!2780
This commit is contained in:
commit
a7efce14e0
@ -4653,6 +4653,7 @@ g_main_context_add_poll_unlocked (GMainContext *context,
|
|||||||
context->poll_changed = TRUE;
|
context->poll_changed = TRUE;
|
||||||
|
|
||||||
/* Now wake up the main loop if it is waiting in the poll() */
|
/* Now wake up the main loop if it is waiting in the poll() */
|
||||||
|
if (fd != &context->wake_up_rec)
|
||||||
g_wakeup_signal (context->wakeup);
|
g_wakeup_signal (context->wakeup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2349,6 +2349,7 @@ test_maincontext_timeout_once (void)
|
|||||||
{
|
{
|
||||||
guint counter = 0, check_counter = 0;
|
guint counter = 0, check_counter = 0;
|
||||||
guint source_id;
|
guint source_id;
|
||||||
|
gint64 t;
|
||||||
GSource *source;
|
GSource *source;
|
||||||
|
|
||||||
g_test_summary ("Test g_timeout_add_once() works");
|
g_test_summary ("Test g_timeout_add_once() works");
|
||||||
@ -2360,6 +2361,8 @@ test_maincontext_timeout_once (void)
|
|||||||
|
|
||||||
/* Iterating the main context should dispatch the source, though we have to block. */
|
/* Iterating the main context should dispatch the source, though we have to block. */
|
||||||
g_assert_cmpuint (counter, ==, 0);
|
g_assert_cmpuint (counter, ==, 0);
|
||||||
|
t = g_get_monotonic_time ();
|
||||||
|
while (g_get_monotonic_time () - t < 50 * 1000 && counter == 0)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
g_assert_cmpuint (counter, ==, 1);
|
g_assert_cmpuint (counter, ==, 1);
|
||||||
|
|
||||||
@ -2367,6 +2370,8 @@ test_maincontext_timeout_once (void)
|
|||||||
* timeout and block until that is dispatched. Given the ordering guarantees,
|
* timeout and block until that is dispatched. Given the ordering guarantees,
|
||||||
* we should then know whether the first one would have re-dispatched by then. */
|
* we should then know whether the first one would have re-dispatched by then. */
|
||||||
g_timeout_add_once (30 /* ms */, once_cb, &check_counter);
|
g_timeout_add_once (30 /* ms */, once_cb, &check_counter);
|
||||||
|
t = g_get_monotonic_time ();
|
||||||
|
while (g_get_monotonic_time () - t < 50 * 1000 && check_counter == 0)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
g_assert_cmpuint (check_counter, ==, 1);
|
g_assert_cmpuint (check_counter, ==, 1);
|
||||||
g_assert_cmpuint (counter, ==, 1);
|
g_assert_cmpuint (counter, ==, 1);
|
||||||
|
@ -295,10 +295,12 @@ test_spawn_async_with_fds (void)
|
|||||||
|
|
||||||
if (test_pipe[1][0] >= 0)
|
if (test_pipe[1][0] >= 0)
|
||||||
{
|
{
|
||||||
|
gchar *tmp = g_strdup_printf ("# thread %d" LINEEND, tnum);
|
||||||
/* Check for echo on stdout */
|
/* Check for echo on stdout */
|
||||||
g_assert_true (data.stdout_done);
|
g_assert_true (data.stdout_done);
|
||||||
g_assert_cmpstr (data.stdout_buf->str, ==, arg);
|
g_assert_cmpstr (data.stdout_buf->str, ==, tmp);
|
||||||
g_io_channel_unref (channel);
|
g_io_channel_unref (channel);
|
||||||
|
g_free (tmp);
|
||||||
}
|
}
|
||||||
g_string_free (data.stdout_buf, TRUE);
|
g_string_free (data.stdout_buf, TRUE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user