At 12:29 AM 3/29/2006, Pierangelo Masarati wrote: >I fear yet more few minor concurrency issues in libldap; I'd like to be >able to assert if a mutex is locked from inside library functions, and it >would be great to also know who's locking it. >What I'd do is > >#define ISLOCKED(m) \ > ( ldap_pvt_mutex_trylock( (m) ) ? 1 \ > : ( ldap_pvt_mutex_unlock( (m) ), 0 ) ) > >Comments?
Note that this can 0 in the case where the current thread already holds the lock and the underlying thread library provides reentrant locking; and can return 1 when the current thread holds the lock and the underlying thread library doesn't provide reentrant locking. But as Hallvard asks, what use is this information given its validity would be void before it could possibly used? Lastly, if you want to know who has the lock, you need to build that on-top of the mutexes as most (if not all) of the threading packages we use do not expose interfaces report who holds a mutex. Kurt >p. > > > >Ing. Pierangelo Masarati >Responsabile Open Solution >OpenLDAP Core Team > >SysNet s.n.c. >Via Dossi, 8 - 27100 Pavia - ITALIA >http://www.sys-net.it >------------------------------------------ >Office: +39.02.23998309 >Mobile: +39.333.4963172 >Email: [EMAIL PROTECTED] >------------------------------------------
