Broken locking in old AddOnManager

"Axel Dörfler" <[email protected]> Fri, 23 Jan 2004 09:01:04 +0100 CET
Newsgroups gmane.os.openbeos.mediakit
Message-ID <29261041383-BeMail@nichtsnutz>
Hi there,

just to note it here, since I forgot to put it into the CVS change 
message:

Both AddOnManager::RegisterReader()/Decoder() had a broken locking 
strategy:

void
AddOnManager::RegisterReader()
{
	1) lock
		check if the reader already exists
	unlock

	... initialize reader ...

	2) lock
		add reader
	unlock
}

When you lock again in 2), the same reader could have been added in the 
meantime; you would have to check for its existence again.
It's better in this case to hold the lock during the whole time, given 
that the whole process is relatively light-weight.

Bye,
   Axel.