mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-14 05:16:18 +01:00
GCond: check result of pthread_condattr_setclock()
Make sure this call succeeds, aborting if it doesn't This will prevent people from having to waste time chasing down the problems that would otherwise be caused by this silent failure.
This commit is contained in:
parent
03a43c290e
commit
5103c5d643
@ -639,8 +639,13 @@ g_cond_impl_new (void)
|
|||||||
gint status;
|
gint status;
|
||||||
|
|
||||||
pthread_condattr_init (&attr);
|
pthread_condattr_init (&attr);
|
||||||
#if defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)
|
|
||||||
pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
|
#ifdef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
|
||||||
|
#elif defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)
|
||||||
|
if G_UNLIKELY ((status = pthread_condattr_setclock (&attr, CLOCK_MONOTONIC)) != 0)
|
||||||
|
g_thread_abort (status, "pthread_condattr_setclock");
|
||||||
|
#else
|
||||||
|
#error Cannot support GCond on your platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cond = malloc (sizeof (pthread_cond_t));
|
cond = malloc (sizeof (pthread_cond_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user