Add runtime checks and a fallback if we can't get the thread scheduler settings

On Linux the sched_getattr syscall might be available at compile-time
but not actually work at runtime (e.g. because an older kernel is
running or valgrind is used). Instead of killing the process, return
FALSE and handle this gracefully at runtime with some fallback code.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/2007
This commit is contained in:
Sebastian Dröge
2020-01-18 13:23:30 +02:00
parent 457ea97c75
commit 012660b8fa
5 changed files with 46 additions and 33 deletions

View File

@@ -902,11 +902,12 @@ g_thread_new_internal (const gchar *name,
name, func, data, error);
}
void
gboolean
g_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_settings)
{
g_return_if_fail (scheduler_settings != NULL);
g_system_thread_get_scheduler_settings (scheduler_settings);
g_return_val_if_fail (scheduler_settings != NULL, FALSE);
return g_system_thread_get_scheduler_settings (scheduler_settings);
}
/**