aboutsummaryrefslogtreecommitdiff
path: root/net/openh323-112/files/patch-aa
blob: cf262107575ce3341b46a2e3b4155b3e079c30dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
*** ../pwlib/src/ptlib/unix/tlibthrd.cxx.orig	Thu Nov 16 11:14:48 2000
--- ../pwlib/src/ptlib/unix/tlibthrd.cxx	Thu Nov 16 11:15:21 2000
*************** void PThread::PX_NewThread(BOOL startSus
*** 386,391 ****
--- 386,409 ----
  //  pthread_attr_t threadAttr;
  //  pthread_attr_init(&threadAttr);
    PAssertOS(pthread_create(&PX_threadId, NULL, PX_ThreadStart, this) == 0);
+ 
+ #if defined(P_FREEBSD)
+   // There is a potential race condition here which shows up with FreeBSD 4.2
+   // and later, but really applies to all pthread libraries.
+   // If a thread is started in suspend mode, we need to make sure
+   // the thread (PX_ThreadStart) has had a chance to execute and block on the
+   // sigwait() (blocking on the Resume Signal) before this function returns.
+   // Otherwise the main program may issue a Resume Signal on the thread
+   // by calling PThread::Resume() before the thread is ready for it.
+   // If that happens the program will abort with an unhandled signal error.
+   // A workaround (not 100% guaranteed) is to yield here, which gives
+   // the newly created thread (PX_ThreadStart) a chance to execute.
+  
+   if (startSuspended) {
+     sched_yield();
+   }
+ #endif
+ 
  }