]> git.sesse.net Git - vlc/commitdiff
Fix race condition if multiple threads delete the same HTTP host
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 2 Jul 2009 16:06:26 +0000 (19:06 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 2 Jul 2009 16:06:26 +0000 (19:06 +0300)
src/network/httpd.c

index 7bfc071f04a2e7ad0bdd0a3fb1e7a1a81b03e65d..8f4b0f83e3df6422ffa04704cdde32665a0d2482 100644 (file)
@@ -1150,15 +1150,19 @@ void httpd_HostDelete( httpd_host_t *host )
 {
     httpd_t *httpd = host->httpd;
     int i;
+    bool delete = false;
 
     vlc_mutex_lock( &httpd_mutex );
 
     vlc_mutex_lock( &host->lock );
     host->i_ref--;
     if( host->i_ref == 0 )
+    {
         vlc_cond_signal( &host->wait );
+        delete = true;
+    }
     vlc_mutex_unlock( &host->lock );
-    if( host->i_ref > 0 )
+    if( !delete )
     {
         /* still used */
         vlc_mutex_unlock( &httpd_mutex );