the problem I'm having started to appear lately and it doesn't appear everywhere.
The front end (html/js) calls PHP pages. PHP in turn calls functions from a COM dll (vb6). The COM dll does use some lower level C++ .dlls in turns, though not sure this information is relevant.
Now, lately (this did not happen before), in one specific COM dll function, let's call it BringClients()
, sometimes (apparently some user concurrency happening - race condition?) a global variable let's say ClientName
which is used within BringClients()
is not empty when the function is called, but instead it holds a value, which is set on function UpdateClients()
when this function is called in a completely different instance of the COM dll, by a completely different user.
I don't know why this is happening. Aren't all COM dll variables empty when the .dll is initialized? I worked around it by manually emptying the variable on each initilization of the .dll, but should this even be happening? I haven't noticed a similar issue on other functions.
The OS is Windows server with IIS.
I don't know how PHP interacts with COM components, but my guess is you don't really initialize the DLL, you create objects. And your COM library is apartment-threaded, so you will get an isolated set of variables per thread.
But what happens if IIS uses the same thread later (from a pool) based upon whatever scheduling it uses to balance requests? Then any global/public module-level data variables will still be there.
So yes, if you need to ensure that those variables are not re-used you are going to have to clear them or re-architect to remove all globals.