[daemon-fix] fixed querying about name information
[platform/upstream/dbus.git] / dbus / dbus-sysdeps-pthread.c
index 9758934..1300ec3 100644 (file)
 
 #include <config.h>
 
+#ifdef HAVE_MONOTONIC_CLOCK
 /* Whether we have a "monotonic" clock; i.e. a clock not affected by
  * changes in system time.
  * This is initialized once in check_monotonic_clock below.
  * https://bugs.freedesktop.org/show_bug.cgi?id=18121
  */
 static dbus_bool_t have_monotonic_clock = 0;
+#endif
 
 struct DBusRMutex {
   pthread_mutex_t lock; /**< the lock */
@@ -262,12 +264,6 @@ _dbus_platform_condvar_wake_one (DBusCondVar *cond)
   PTHREAD_CHECK ("pthread_cond_signal", pthread_cond_signal (&cond->cond));
 }
 
-void
-_dbus_platform_condvar_wake_all (DBusCondVar *cond)
-{
-  PTHREAD_CHECK ("pthread_cond_broadcast", pthread_cond_broadcast (&cond->cond));
-}
-
 static void
 check_monotonic_clock (void)
 {
@@ -281,6 +277,26 @@ check_monotonic_clock (void)
 dbus_bool_t
 _dbus_threads_init_platform_specific (void)
 {
+  /* These have static variables, and we need to handle both the case
+   * where dbus_threads_init() has been called and when it hasn't;
+   * so initialize them before any threads are allowed to enter.
+   */
   check_monotonic_clock ();
-  return dbus_threads_init (NULL);
+  (void) _dbus_check_setuid ();
+
+  return TRUE;
+}
+
+static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+void
+_dbus_threads_lock_platform_specific (void)
+{
+  pthread_mutex_lock (&init_mutex);
+}
+
+void
+_dbus_threads_unlock_platform_specific (void)
+{
+  pthread_mutex_unlock (&init_mutex);
 }