[haiku-commits] r33779 - haiku/trunk/src/system/libroot/posix/pthread

  • From: korli@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 26 Oct 2009 20:28:14 +0100 (CET)

Author: korli
Date: 2009-10-26 20:28:14 +0100 (Mon, 26 Oct 2009)
New Revision: 33779
Changeset: http://dev.haiku-os.org/changeset/33779/haiku

Modified:
   haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c
Log:
Patch from Olivier Coursiere (ticket #4064): cond_wait always return EAGAIN 
with an unitialized pthread_cond_t


Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c
===================================================================
--- haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2009-10-26 
18:35:46 UTC (rev 33778)
+++ haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2009-10-26 
19:28:14 UTC (rev 33779)
@@ -82,9 +82,11 @@
                // Note, this is thread-safe, since another thread would be 
required to
                // hold the same mutex.
                sem_id sem = create_sem(0, "pthread_cond");
-               if (cond->sem < 0)
+               if (sem < 0)
                        return EAGAIN;
-               cond->sem = sem;
+
+               if (atomic_test_and_set((vint32*)&cond->sem, sem, -42) != -42)
+                       delete_sem(sem);
        }
 
        if (cond->mutex && cond->mutex != mutex)


Other related posts:

  • » [haiku-commits] r33779 - haiku/trunk/src/system/libroot/posix/pthread - korli