Paul Vriens Paul.Vriens at
Tue Jan 11 06:13:53 CST 2005

On Tue, 2005-01-11 at 12:19, Christian Costa wrote:

> All the time ?
> Looking at COM_CreateApartment it seems COINIT_APARTMENTTHREADED works but indeed COINIT_MULTITHREADED always return NULL.
> I think the code at the beginning of COM_CreateApartment is wrong.
>             TRACE("thread 0x%lx is entering the multithreaded apartment\n", GetCurrentThreadId());
>             COM_CurrentInfo()->apt = &MTA;
>             return apt;
> I think we should return COM_CurrentInfo()->apt rather than apt.
> Bye,
> Christian
Just another thing.

shouldn't s_COMLockCount be a per thread thing? Currently it's global.

What I personally find strange is the behavior of InterlockedExchangeAdd
especially with respect to the comments in compobj.c:

   * Check the lock count. If this is the first time going through the
   * process, we have to initialize the libraries.
   * And crank-up that lock count.
  lCOMRefCnt = InterlockedExchangeAdd(&s_COMLockCount,1);
  TRACE("s_COMLockCount is now: %08lx\n", lCOMRefCnt);

  if (lCOMRefCnt==0)


   * Decrease the reference count.
   * If we are back to 0 locks on the COM library, make sure we free
   * all the associated data structures.
  lCOMRefCnt = InterlockedExchangeAdd(&s_COMLockCount,-1);
  TRACE("s_COMLockCount is now: %08lx\n", lCOMRefCnt);
  if (lCOMRefCnt==1)

The TRACE is something I added. 

The comments say 'If this is the first time' and the check is for '==0'
and 'If we are back to 0' but the check is for '==1'. A bit confusing.


More information about the wine-devel mailing list