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 7bfc071..8f4b0f8 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 );