
| email this FAQ to a colleague
Q: Should I not use Thread Local Storage (TLS) in an ISAPI App? A: In some situations (depending on where and how you allocate thread local storage) this is true. However, because under Win NT, every DLL is
guaranteed to have DllMain called with a "thread detach" reason code (under normal process termination), using TLS is safe as long as you are
sure to deallocate everything in response to this reason code. In the event of abnormal process termination, a lot more will be leaked anyway. What John was trying to say is that you never know on what thread you might be called (inside an ISAPI DLL), so using TLS for anything other
than tracking resources that are explicitly bound to a particular thread is a bad idea. In the case of OLE, all calls are bound explicitly to the specific thread you are called on or calling from (in the apartment threading model), so using TLS is actually the best way to monitor your
initialization state. You can reference the OLEISAPI example as a reference (TLS is used there to flag whether OLE has been initialized for the current
thread or not). - Travis James | Books | | | | Using ISAPI | | Stephen Genusa, Bobby, Jr Addison, Allen Clark, Dean Cleaver |
| |
|