Commit 28afd1fc authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Suppress httpd_mutex variable

parent 220001b9
...@@ -975,6 +975,7 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, const char *psz_host, ...@@ -975,6 +975,7 @@ httpd_host_t *httpd_HostNew( vlc_object_t *p_this, const char *psz_host,
} }
static const char psz_object_type[] = "http server"; static const char psz_object_type[] = "http server";
static vlc_mutex_t httpd_mutex = VLC_STATIC_MUTEX;
httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname, httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
int i_port, int i_port,
...@@ -985,7 +986,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname, ...@@ -985,7 +986,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
httpd_host_t *host; httpd_host_t *host;
tls_server_t *p_tls; tls_server_t *p_tls;
char *psz_host; char *psz_host;
vlc_value_t lockval, ptrval; vlc_value_t ptrval;
int i; int i;
if( psz_hostname == NULL ) if( psz_hostname == NULL )
...@@ -996,9 +997,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname, ...@@ -996,9 +997,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
return NULL; return NULL;
/* to be sure to avoid multiple creation */ /* to be sure to avoid multiple creation */
var_Create( p_this->p_libvlc, "httpd_mutex", VLC_VAR_MUTEX ); vlc_mutex_lock( &httpd_mutex );
var_Get( p_this->p_libvlc, "httpd_mutex", &lockval );
vlc_mutex_lock( lockval.p_address );
httpd = libvlc_priv (p_this->p_libvlc)->p_httpd; httpd = libvlc_priv (p_this->p_libvlc)->p_httpd;
if( httpd == NULL ) if( httpd == NULL )
...@@ -1009,7 +1008,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname, ...@@ -1009,7 +1008,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
psz_object_type ); psz_object_type );
if( httpd == NULL ) if( httpd == NULL )
{ {
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( &httpd_mutex );
free( psz_host ); free( psz_host );
return NULL; return NULL;
} }
...@@ -1042,7 +1041,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname, ...@@ -1042,7 +1041,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
host->i_ref++; host->i_ref++;
vlc_mutex_unlock( &host->lock ); vlc_mutex_unlock( &host->lock );
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( &httpd_mutex );
return host; return host;
} }
...@@ -1119,7 +1118,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname, ...@@ -1119,7 +1118,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
/* now add it to httpd */ /* now add it to httpd */
TAB_APPEND( httpd->i_host, httpd->host, host ); TAB_APPEND( httpd->i_host, httpd->host, host );
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( &httpd_mutex );
return host; return host;
...@@ -1132,7 +1131,7 @@ error: ...@@ -1132,7 +1131,7 @@ error:
vlc_object_detach( httpd ); vlc_object_detach( httpd );
vlc_object_release( httpd ); vlc_object_release( httpd );
} }
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( &httpd_mutex );
if( host != NULL ) if( host != NULL )
{ {
...@@ -1152,11 +1151,9 @@ error: ...@@ -1152,11 +1151,9 @@ error:
void httpd_HostDelete( httpd_host_t *host ) void httpd_HostDelete( httpd_host_t *host )
{ {
httpd_t *httpd = host->httpd; httpd_t *httpd = host->httpd;
vlc_value_t lockval;
int i; int i;
var_Get( httpd->p_libvlc, "httpd_mutex", &lockval ); vlc_mutex_lock( &httpd_mutex );
vlc_mutex_lock( lockval.p_address );
vlc_mutex_lock( &host->lock ); vlc_mutex_lock( &host->lock );
host->i_ref--; host->i_ref--;
...@@ -1166,7 +1163,7 @@ void httpd_HostDelete( httpd_host_t *host ) ...@@ -1166,7 +1163,7 @@ void httpd_HostDelete( httpd_host_t *host )
if( host->i_ref > 0 ) if( host->i_ref > 0 )
{ {
/* still used */ /* still used */
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( &httpd_mutex );
msg_Dbg( host, "httpd_HostDelete: host still used" ); msg_Dbg( host, "httpd_HostDelete: host still used" );
return; return;
} }
...@@ -1212,7 +1209,7 @@ void httpd_HostDelete( httpd_host_t *host ) ...@@ -1212,7 +1209,7 @@ void httpd_HostDelete( httpd_host_t *host )
vlc_object_release( httpd ); vlc_object_release( httpd );
} }
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( &httpd_mutex );
} }
/* register a new url */ /* register a new url */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment