Fixed Barrier test. First get the thread ID, then wait for the barrier to be reached.
authorArmin Novak <armin.novak@thincast.com>
Tue, 2 Sep 2014 08:20:12 +0000 (10:20 +0200)
committerArmin Novak <armin.novak@thincast.com>
Tue, 9 Sep 2014 14:33:05 +0000 (16:33 +0200)
winpr/libwinpr/synch/test/TestSynchBarrier.c

index ebdcc7c..6b22580 100644 (file)
@@ -11,16 +11,16 @@ static SYNCHRONIZATION_BARRIER g_Barrier;
 static void* test_synch_barrier_thread_func(void* arg)
 {
        BOOL status;
-
-       status = EnterSynchronizationBarrier(&g_Barrier, 0);
+  int count;
 
        EnterCriticalSection(&g_Lock);
+  count = g_Count++;
+       LeaveCriticalSection(&g_Lock);
+       status = EnterSynchronizationBarrier(&g_Barrier, 0);
 
-       printf("Thread #%d status: %s\n", g_Count++,
+       printf("Thread #%d status: %s\n", count,
                        status ? "TRUE" : "FALSE");
 
-       LeaveCriticalSection(&g_Lock);
-
        if (status)
        {
                SetEvent(g_Event);