mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 09:46:17 +01:00
tests: Rework a mainloop test to use an explicit termination condition
And to not assume that every main context iteration will provide progress on the sources that the test is interested in. It’s possible that other sources may be attached to the `GMainContext` which get dispatched instead of the pipe sources on an iteration. I don’t know if this will fix #3483, but it will certainly make this test a little tidier. It doesn’t affect test run time. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Fixes: #3483
This commit is contained in:
parent
cc2b78ec47
commit
a40a33dfe0
@ -1328,14 +1328,17 @@ test_unix_fd (void)
|
|||||||
/* Assuming the kernel isn't internally 'laggy' then there will always
|
/* Assuming the kernel isn't internally 'laggy' then there will always
|
||||||
* be either data to read or room in which to write. That will keep
|
* be either data to read or room in which to write. That will keep
|
||||||
* the loop running until all data has been read and written.
|
* the loop running until all data has been read and written.
|
||||||
|
*
|
||||||
|
* We can’t rely on the data being available in exactly one `GMainContext`
|
||||||
|
* iteration, though, as it may be potentially deferred in favour of higher
|
||||||
|
* priority sources.
|
||||||
*/
|
*/
|
||||||
while (TRUE)
|
while (to_write > 0 || to_read > 0)
|
||||||
{
|
{
|
||||||
gssize to_write_was = to_write;
|
gssize to_write_was = to_write;
|
||||||
gssize to_read_was = to_read;
|
gssize to_read_was = to_read;
|
||||||
|
|
||||||
if (!g_main_context_iteration (NULL, FALSE))
|
g_main_context_iteration (NULL, TRUE);
|
||||||
break;
|
|
||||||
|
|
||||||
/* Since the sources are at different priority, only one of them
|
/* Since the sources are at different priority, only one of them
|
||||||
* should possibly have run.
|
* should possibly have run.
|
||||||
|
Loading…
Reference in New Issue
Block a user