Ticket #4064: pthread_cond.c.alt_2.diff

File pthread_cond.c.alt_2.diff, 543 bytes (added by oco, 15 years ago)

Second patch

  • pthread_cond.c

     
    8282        // Note, this is thread-safe, since another thread would be required to
    8383        // hold the same mutex.
    8484        sem_id sem = create_sem(0, "pthread_cond");
    85         if (cond->sem < 0)
     85        if (sem < 0)
    8686            return EAGAIN;
    87         cond->sem = sem;
     87
     88        if (atomic_test_and_set((vint32*)&cond->sem, sem, -42) != -42)
     89            delete_sem(sem);
    8890    }
    8991
    9092    if (cond->mutex && cond->mutex != mutex)