You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Tim Hudson <tj...@cryptsoft.com> on 1998/05/31 05:17:05 UTC

Re: [PHP-DEV] Interesting thread problem in windows...

> ---------- Forwarded message ----------
> Date: Sat, 30 May 1998 19:45:29 -0400
> From: Shane Caraveo <sh...@caraveo.com>
> To: php-dev@php.iquest.net
> Subject: [PHP-DEV] Interesting thread problem in windows...
> 
> Hello everyone,
> I've hit on an interesting problem.  I was wondering if there are any other
> windows programmers out there who might have an idea.  I'm working on the
> isapi module, and have a dllmain function which handles process and thread
> attach and detach.  For some reason not *all*, but *some* threads run the
> thread attach section.  The ones that do not then fail because the dll has
> not been initialized the way it should be.  As I understand it, all threads
> that attach to a dll, except the first to attach, are supposed to run
> dllmain with reason for call being DLL_THREAD_ATTACH.
    
    This is a fairly common misconception ... you only get DLL_THREAD_ATTACH 
for new threads that are created *after* your DLL is loaded into an application.
Any existing threads that the process has don't provide this notification
and in fact it is quite normal to get called in a DLL by threads that have
not "attached".

    Specially, IIS has pools of threads and certainly you will have ISAPI
activity for threads that have not "attached". You have to cut your DLL
code to allow for this. GetCurrentThreadId() is your friend ... if your
DLL is structed to only do initialisation for a thread on DLL_THREAD_ATTACH
then it will fail for applications like IIS. Some minor restructuring should
fix this problem.

Tim.