[vlc-devel] [PATCH 4/5] upnp: do not delete the UpnpInstanceWrapper instance under s_lock

Steve Lhomme robux4 at videolabs.io
Thu Jun 2 14:08:19 CEST 2016


It calls UpnpFinish() which might wait for some callbacks to finish and they
may be locked with s_lock.
---
 modules/services_discovery/upnp.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 09d94fc..3ea5bde 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -1298,7 +1298,8 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, services_disc
 
 void UpnpInstanceWrapper::release(bool isSd)
 {
-    vlc_mutex_locker lock( &s_lock );
+    UpnpInstanceWrapper *p_delete = NULL;
+    vlc_mutex_lock( &s_lock );
     if ( isSd )
     {
         delete UpnpInstanceWrapper::p_server_list;
@@ -1306,9 +1307,11 @@ void UpnpInstanceWrapper::release(bool isSd)
     }
     if (--s_instance->m_refcount == 0)
     {
-        delete s_instance;
+        p_delete = s_instance;
         s_instance = NULL;
     }
+    vlc_mutex_unlock( &s_lock );
+    delete p_delete;
 }
 
 UpnpClient_Handle UpnpInstanceWrapper::handle() const
-- 
2.8.1



More information about the vlc-devel mailing list