>>>>> +STDAPI DllCanUnloadNow() >>>>> +{ >>>>> + return g_nComObjsInUse == 0 ? S_OK : S_FALSE; >>>>> +} >> >> Don't you need some kind of atomic or locked read here? We could read a >> stale value here. Granted, most stale values would err on the safe side >> (ie. read >0 instead of ==0), but in theory the other mistake is >> possible, no? > > MSDN says "Simple reads and writes to properly-aligned 32bit variables > are atomic", and I couldn't find a function to atomic read provided. > (Maybe InterlockedCompareExchange(&g_nComObjsInUse, 0, 0)...?)
Alright then. Thanks! Laszlo