From: RĂ©mi Denis-Courmont Date: Thu, 2 Jul 2009 16:06:26 +0000 (+0300) Subject: Fix race condition if multiple threads delete the same HTTP host X-Git-Tag: 1.1.0-ff~5145 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=619185607efae0fb2d23bb466510edde08a795a8;p=vlc Fix race condition if multiple threads delete the same HTTP host --- diff --git a/src/network/httpd.c b/src/network/httpd.c index 7bfc071f04..8f4b0f83e3 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 );