directory: Use finite amount of tries for self check

Turn potentially infinite while loops into for loops with finite
amount of repetitions. In general 1000 tries should be sufficient,
so the chosen amount of 100.000 serves as an upper limit.

See https://gitlab.gnome.org/GNOME/nautilus/-/issues/1290
This commit is contained in:
Peter 2021-02-13 22:57:21 +01:00 committed by António Fernandes
parent 2103a487a0
commit b151025d3e

View file

@ -2028,7 +2028,7 @@ nautilus_self_check_directory (void)
nautilus_directory_unref (directory);
while (g_hash_table_size (directories) != 0)
for (guint i = 0; g_hash_table_size (directories) != 0 && i < 100000; i++)
{
gtk_main_iteration ();
}
@ -2045,11 +2045,13 @@ nautilus_self_check_directory (void)
TRUE,
got_files_callback, &data_dummy);
while (!got_files_flag)
for (guint i = 0; !got_files_flag && i < 100000; i++)
{
gtk_main_iteration ();
}
EEL_CHECK_BOOLEAN_RESULT (got_files_flag, TRUE);
EEL_CHECK_BOOLEAN_RESULT (directory->details->file_list == NULL, TRUE);
EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1);