COM-call and critical sections

From: Dirk Hennings (dhennings_at_gmx.de)
Date: 03/29/04


Date: Mon, 29 Mar 2004 01:28:55 +0200

Hi,

I am working with a Client-Application sending data to a COM-Server.

The COM-Server starts working when the Client-Application pushes data into
the queue.
In my COM-Server multiple threads are working with each other, secured by
critical sections.
Everything works fine - I checked the critical sections, debugged and used
some Thread-Validators. No problems.

But sometimes when I push new data to the COM-Server while the queue is
working on the data it happens (that's what the critical sections are for
;-)) that the critical section is already locked.
The client-application's call is executed in the main-thread (debugged by
me):
Thread 2 (COM-Server) runs into the criticalsection. lockcount=0 and
extracts data to be worked on.
MainThread 1 (call by client-application) runs into the same
criticalsection.

What happens now?
If the mainthread wouldn't run into the criticalsection because of the
client-application's call, but some other thread would do so, then no
problems would accour.
So I would expect the Thread2 to take the steps to extract the data and
leave the critical section, but... nope!
Thread1 and Thread2 are both freezed and no return in sight!
Deadlock and I have no idea why?

Am I missing something?
Is this the case because of a call from my client-application through COM?
Is this because it's the MainThread?

I have absolutely no idea why this happens.

Any help greatly appriciated.
Thanks in advance

Dirk