Proposed fix (3 steps):
1. Add a little helper class, that does unlock() during destruction.
Code: Select all
/** Automatically unlocks the specified read/write lock when it goes out of scope.
*/
class AutoUnlock
{
OFReadWriteLock& readWriteLock;
public:
/** explicit constructor */
explicit AutoUnlock(OFReadWriteLock& arg) : readWriteLock(arg)
{
}
/** destructor */
~AutoUnlock()
{
readWriteLock.unlock();
}
private:
/** unimplemented private copy constructor */
AutoUnlock(const AutoUnlock& arg);
/** unimplemented private assignment operator */
AutoUnlock& operator=(const AutoUnlock& arg);
};
3. Declare a local AutoUnlock object at the begin of each scope that is opened after if (0 == codecLock.XXlock()). Hereby XXlock() is either rdlock() or wrlock(), for example:
Code: Select all
#ifdef _REENTRANT
if (0 == codecLock.rdlock())
{
const AutoUnlock constAutoUnlock(codecLock);
#endif
Hope you can take a look at this issue. If you want, I can send you a patched version of dccodec.cc.
Niels
(*) I'm not entirely sure if "deadlock" is the right term here, but certainly, it blocks the program.