[vlc-devel] [PATCH v6 3/7] upnp: Split s_lock into two locks to solve deadlock issue

Johan Gunnarsson johan.gunnarsson at gmail.com
Fri Dec 6 20:50:20 CET 2019


Den ons 4 dec. 2019 kl 21:56 skrev Rémi Denis-Courmont <remi at remlab.net>:
>
> Le keskiviikkona 4. joulukuuta 2019, 22.39.59 EET Johan Gunnarsson a écrit :
> > If libupnp executes a callback while vlc runs UpnpInstanceWrapper dtor, vlc
> > will deadlock. This happens because the callback handler and
> > UpnpInstanceWrapper dtor both takes s_lock, and Upnp_Finish waits for all
> > callbacks to finish. UpnpUnRegisterRootDevice causes libupnp to broadcast
> > "byebye" advertisements, which libupnp picks up again and delivers as
> > callbacks.
> >
> > This patch separates the locks into one that protects the
> > UpnpInstanceWrapper refcounts and one that protects the list of listeners.
>
> AFAICT, an UPnP instance as a whole is not thread-safe, so you cannot split
> locks without inducing races inside the library.

Not quite sure which code paths can race. Can you enlighten me? My
point is I can't hold s_lock_listeners while calling UpnpFinish. That
will deadlock.

Maybe I can take s_lock_listeners in UpnpInstanceWrapper::get,
UpnpInstanceWrapper::startMediaRenderer,
UpnpInstanceWrapper::stopMediaRenderer and
UpnpInstanceWrapper::~UpnpInstanceWrapper, but release it right before
UpnpFinish?

>
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list