[vlc-devel] [PATCH v4 2/3] Update media tree on browsing/preparsing

Romain Vimont rom1v at videolabs.io
Tue Jul 10 15:27:56 CEST 2018


On Mon, Jul 09, 2018 at 08:36:56PM +0300, Rémi Denis-Courmont wrote:
> Le maanantaina 9. heinäkuuta 2018, 13.13.53 EEST Romain Vimont a écrit :
> > Browsing and preparsing, started by libvlc_MetadataRequest(), trigger
> > input item events.
> > 
> > Listen to these events to update the media tree accordingly.
> 
> I think that there is a lock inversion here:
> 
> On the one hand, in vlc_media_tree_Remove(), the media tree lock is taken 
> first, then input item events are unregistering, taking the event manager lock 
> of the respective input item. On the other hand, in input item event 
> callbacks, the media tree gets locked while the event manager lock is held.

Wow, that's very true.

There's the same problem in the current code in the playlist:
https://git.videolan.org/?p=vlc.git;a=blob;f=src/playlist/item.c;h=4458de84350f5c99b9f1945a02a27be05155be88;hb=HEAD#l309
https://git.videolan.org/?p=vlc.git;a=blob;f=src/playlist/item.c;h=4458de84350f5c99b9f1945a02a27be05155be88;hb=HEAD#l53

We want to attach/detach callbacks when we add/remove an item to the
tree, and we want to modify the tree when the callback is triggered.

For now, I can't think of an elegant+correct solution. Do you have any
suggestions?


More information about the vlc-devel mailing list