Unpleasant race condition in pj_thread_create

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the Windows version (os_core_win32.c) of "pj_thread_create" the newly 
created thread may run for some time before the thread handle is 
returned by "CreateThread" and assigned to "rec->hthread". If this new 
thread calls "pj_thread_this" and attempts to use the handle (in, say, a 
call to "pj_thread_get_prio") it will fail because the handle has not 
yet been assigned. It's happened to me several times. I suggest in 
os_core_win32.c that the thread get created suspended, and after the 
handle has been assigned it be resumed if the flags do not request it 
created suspended.

Also, might I suggest that instead of using "CreateThread" you should 
use the C library function "_beginthreadex", since a Windows build surly 
links to the C library and using "_beginthreadex" will avoid the memory 
leaks you get when the thread is exited.

John Ridges





[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux