
|
[openbeosmediakit]
||
[Date Prev]
[01-2004 Date Index]
[Date Next]
||
[Thread Prev]
[01-2004 Thread Index]
[Thread Next]
[openbeosmediakit] Aw: Broken locking in old AddOnManager
- From: Marcus Overhagen <marcusoverhagen@xxxxxxxx>
- To: openbeosmediakit@xxxxxxxxxxxxx
- Date: Fri, 23 Jan 2004 09:42:05 +0100 (CET)
> 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.
>
Well the idea was that RegisterReader() is only called from RegisterAddOns()
which is only executed once during startup (and only from a single thread).
The lock is only used to preserve list integrity (Rewind() changes internal
list pointer).
As soon as we implement node watching to dynamically register/unregister
plugins,
will get more complicated, but I still think this locking is ok.
Marcus
|

|