Remove HTTPD object type
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 30 Mar 2008 13:35:31 +0000 (16:35 +0300)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 30 Mar 2008 14:15:09 +0000 (17:15 +0300)
include/vlc_objects.h
modules/misc/lua/objects.c
src/network/httpd.c

index 196a41b..74e87bf 100644 (file)
@@ -47,7 +47,7 @@
 #define VLC_OBJECT_VOUT        (-9)
 #define VLC_OBJECT_AOUT        (-10)
 #define VLC_OBJECT_SOUT        (-11)
-#define VLC_OBJECT_HTTPD       (-12)
+
 #define VLC_OBJECT_PACKETIZER  (-13)
 #define VLC_OBJECT_ENCODER     (-14)
 #define VLC_OBJECT_DIALOGS     (-15)
index 65f1b5e..9feff68 100644 (file)
@@ -117,7 +117,6 @@ static int vlc_object_type_from_string( const char *psz_name )
           { VLC_OBJECT_VOUT, "vout" },
           { VLC_OBJECT_AOUT, "aout" },
           { VLC_OBJECT_SOUT, "sout" },
-          { VLC_OBJECT_HTTPD, "httpd" },
           { VLC_OBJECT_PACKETIZER, "packetizer" },
           { VLC_OBJECT_ENCODER, "encoder" },
           { VLC_OBJECT_DIALOGS, "dialogs" },
index 79f96f2..d2d76fc 100644 (file)
@@ -981,7 +981,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
     httpd_host_t *host;
     tls_server_t *p_tls;
     char *psz_host;
-    vlc_value_t  lockval;
+    vlc_value_t  lockval, ptrval;
     int i;
 
     if( psz_hostname == NULL )
@@ -996,14 +996,18 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
 
     /* to be sure to avoid multiple creation */
     var_Create( p_this->p_libvlc, "httpd_mutex", VLC_VAR_MUTEX );
+    var_Create( p_this->p_libvlc, "httpd_object", VLC_VAR_ADDRESS );
     var_Get( p_this->p_libvlc, "httpd_mutex", &lockval );
     vlc_mutex_lock( lockval.p_address );
+    var_Get( p_this->p_libvlc, "httpd_object", &ptrval );
 
-    if( !(httpd = vlc_object_find( p_this, VLC_OBJECT_HTTPD, FIND_ANYWHERE )) )
+    if( ptrval.p_address != NULL )
+        httpd = ptrval.p_address;
+    else
     {
         msg_Info( p_this, "creating httpd" );
         httpd = (httpd_t *)vlc_custom_create( p_this, sizeof (*httpd),
-                                              VLC_OBJECT_HTTPD,
+                                              VLC_OBJECT_GENERIC,
                                               psz_object_type );
         if( httpd == NULL )
         {
@@ -1015,6 +1019,8 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
         httpd->i_host = 0;
         httpd->host   = NULL;
 
+        ptrval.p_address = httpd;
+        var_Set( p_this->p_libvlc, "httpd_object", ptrval );
         vlc_object_yield( httpd );
         vlc_object_attach( httpd, p_this->p_libvlc );
     }
@@ -1191,9 +1197,15 @@ void httpd_HostDelete( httpd_host_t *host )
     vlc_object_release( httpd );
     if( httpd->i_host <= 0 )
     {
+        vlc_value_t ptrval;
+
         msg_Dbg( httpd, "no host left, stopping httpd" );
+
+        ptrval.p_address = NULL;
+        var_Set( httpd->p_libvlc, "httpd_object", ptrval );
         vlc_object_detach( httpd );
         vlc_object_release( httpd );
+
     }
     vlc_mutex_unlock( lockval.p_address );
 }