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

@@ -74,7 +74,7 @@ void g_system_thread_free (GRealThread *thread);
void g_system_thread_exit (void);
void g_system_thread_set_name (const gchar *name);
void g_system_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_settings);
gboolean g_system_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_settings);
/* gthread.c */
GThread *g_thread_new_internal (const gchar *name,
@@ -85,7 +85,7 @@ GThread *g_thread_new_internal (const gchar *name,
const GThreadSchedulerSettings *scheduler_settings,
GError **error);
void g_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_settings);
gboolean g_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_settings);
gpointer g_thread_proxy (gpointer thread);