[vlc-devel] [PATCH 3/4] sout: lock sout_stream_t individually

Rémi Denis-Courmont remi at remlab.net
Mon Oct 12 16:48:23 CEST 2020


Le maanantaina 12. lokakuuta 2020, 10.43.10 EEST Steve Lhomme a écrit :
> On 2020-10-12 9:36, Rémi Denis-Courmont wrote:
> > Hi,
> > 
> > It's needed in two cases, the duplicate module and the core (what the
> > next patch removes). We can add it in duplicate, with a lot of
> > boilerplate. But given that the ES output has a similar internal locking
> > for essentially the same motivation (concurrent ES processed in
> > different threads), it seems logical to move it from sout instance to
> > sout stream instead and share the code.
> > 
> > In the common non-contended case, vlc_mutex_lock is just one atomic op
> > extra.
> 
> Personally I prefer not to lock when I don't have to.

In general, yes, but what does that mean, here? It's one of those scenarii, 
where you have multiple independent callers, so they cannot do the locking. 
Again, both es_out_t and sout_instance_t already have a lock in the equivalent 
place, for the same reasons.

> It's one less possible dead lock to worry about.

The only way this locks dead is if a module reenters itself. If anything, the 
dead lock is far easier to debug than whatever weird bug would stem from this, 
because it will be obvious from the stacktrace.

-- 
Rémi Denis-Courmont
http://www.remlab.net/





More information about the vlc-devel mailing list