<html><head></head><body>Whether this might race or not depends on what thread safety guaranties libupnp provides, if any.<br><br>The fact that there is a lock is a strong hint that it provides none, and if so, it must be operated under a unique lock.<br><br><div class="gmail_quote">Le 6 décembre 2019 20:50:20 GMT+01:00, Johan Gunnarsson <johan.gunnarsson@gmail.com> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Den ons 4 dec. 2019 kl 21:56 skrev Rémi Denis-Courmont <remi@remlab.net>:<br>><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Le keskiviikkona 4. joulukuuta 2019, 22.39.59 EET Johan Gunnarsson a écrit :<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> If libupnp executes a callback while vlc runs UpnpInstanceWrapper dtor, vlc<br> will deadlock. This happens because the callback handler and<br> UpnpInstanceWrapper dtor both takes s_lock, and Upnp_Finish waits for all<br> callbacks to finish. UpnpUnRegisterRootDevice causes libupnp to broadcast<br> "byebye" advertisements, which libupnp picks up again and delivers as<br> callbacks.<br><br> This patch separates the locks into one that protects the<br> UpnpInstanceWrapper refcounts and one that protects the list of listeners.<br></blockquote>AFAICT, an UPnP instance as a whole is not thread-safe, so you cannot split<br>locks without inducing races inside the library.<br></blockquote><br>Not quite sure which code paths can race. Can you enlighten me? My<br>point is I can't hold s_lock_listeners while calling UpnpFinish. That<br>will deadlock.<br><br>Maybe I can take s_lock_listeners in UpnpInstanceWrapper::get,<br>UpnpInstanceWrapper::startMediaRenderer,<br>UpnpInstanceWrapper::stopMediaRenderer and<br>UpnpInstanceWrapper::~UpnpInstanceWrapper, but release it right before<br>UpnpFinish?<br><br>><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> --<br> Rémi Denis-Courmont<br> <a href="http://www.remlab.net/">http://www.remlab.net/</a><hr> vlc-devel mailing list<br> To unsubscribe or modify your subscription options:<br> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>