On Sun, Jun 21, 2009 at 8:13 AM, Hans Leidekkerhans@codeweavers.com wrote:
It appears that calling CreateThread in DLL_PROCESS_ATTACH can cause deadlocks:
There seems to be a better explanation of the deadlock issues at http://blogs.msdn.com/oldnewthing/archive/2007/09/04/4731478.aspx I'm perfectly willing to believe that one should not create threads or wait for them to finish in DllMain, out of an abundance of caution, but I don't see how this particular case could deadlock.
I'm more worried about thread shutdown. It seems wrong to just hope that the thread finishes terminating before DllMain returns and the system calls FreeLibrary, but as oldnewthing explains, you can't wait for a thread to terminate inside DllMain.
It might work if you move it to somewhere near ACTION_CallDllFunction, and wait for the thread to start up, but this remains a hack of course.
What would the elegant solution be?
Another blog explains that inheritance of an existing MTA is just a side effect of starting the custom action in a different process, one that happens to have initialized an MTA already.
Sorry, I'm feeling dense. Which other blog, and what's interesting about that? - Dan