resource managers don't like condvar ?!?

I wasn’t lucky with my previous articles on the subject so, I tried
again differently!

This time, I supply a code to explain my soup!

I have a resource manager capable of locking the access of something
when a client asks for.

So, i have a client which can access normally to the resource if it’s
free, but can also lock and unlock it.

If a client locks the resource, furthers normal access will be blocked
on pthread_cond_wait() until another client asks for the resource
manager to unlock the resource and pthread_cond_broadcast() the waiting

My problem is that when a client is blocked on pthread_cond_wait(), my
ressource manager receive further messages but don’t call my io_msg()
function as it would.


To verify, try the following:


it’s ok if run:
$./thread_pool_cl -l #to lock the resource
$./thread_pool_cl -u #to unlock the resource

but it fail if you run

$./thread_pool_cl -l

in an other shell:

back in the previous shell:
$./thread_pool_cl -u

clients are REPLY blocked!
server is locked on two condvar. One is myne, I don’t where the other
comes from?