[vlc-devel] commit: Fix race condition if multiple threads delete the same HTTP host ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Jul 2 18:07:01 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul  2 19:06:26 2009 +0300| [619185607efae0fb2d23bb466510edde08a795a8] | committer: Rémi Denis-Courmont 

Fix race condition if multiple threads delete the same HTTP host

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=619185607efae0fb2d23bb466510edde08a795a8
---

 src/network/httpd.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 7bfc071..8f4b0f8 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -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 );




More information about the vlc-devel mailing list