Workaround sem_wait failure in pthread_create on Haiku
authorIvan Maidanski <ivmai@mail.ru>
Tue, 6 Mar 2018 22:24:05 +0000 (01:24 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 6 Mar 2018 22:24:05 +0000 (01:24 +0300)
Issue #97 (bdwgc).

sem_wait() fails because of some bug in Haiku OS (as of hrev51798).

* pthread_support.c [GC_HAIKU_THREADS] (WRAP_FUNC(pthread_create)):
If errno is EACCES then just retry sem_wait instead of ABORT.

pthread_support.c

index c12d823..51b4a2b 100644 (file)
@@ -1897,6 +1897,10 @@ GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread(
         DISABLE_CANCEL(cancel_state);
                 /* pthread_create is not a cancellation point. */
         while (0 != sem_wait(&(si -> registered))) {
+#           if defined(GC_HAIKU_THREADS)
+              /* To workaround some bug in Haiku semaphores. */
+              if (EACCES == errno) continue;
+#           endif
             if (EINTR != errno) ABORT("sem_wait failed");
         }
         RESTORE_CANCEL(cancel_state);