Changeset 30267d389073ee38e29728d0246ef5106e9e1f1a

Show
Ignore:
Timestamp:
03/30/08 16:15:09 (5 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1206886509 +0300
git-parent:

[68996a07d479cc6e8dfe92094aa65c005fc05317]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1206885743 +0300
Message:

*Partially* fix the module bank initialization serialization

We should really keep the global "libvlc" lock while initializing the
modules bank. Otherwise, if a second instance is created while the
first one is initializing, it may get an incomplete bank. This commit
addresses the problem w.r.t. the "main" module - only.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/modules.c

    r4772289 r30267d3  
    105105#endif 
    106106 
    107 static void module_LoadMain( vlc_object_t *p_this ); 
    108  
    109107/** 
    110108 * Init bank 
     
    124122    var_Get( p_libvlc_global, "libvlc", &lockval ); 
    125123    vlc_mutex_lock( lockval.p_address ); 
    126     if( p_libvlc_global->p_module_bank ) 
    127     { 
     124 
     125    if( p_libvlc_global->p_module_bank == NULL ) 
     126    { 
     127        p_bank = vlc_object_create( p_this, sizeof(module_bank_t) ); 
     128        p_bank->psz_object_name = "module bank"; 
     129        p_bank->i_usage = 1; 
     130        p_bank->i_cache = p_bank->i_loaded_cache = 0; 
     131        p_bank->pp_cache = p_bank->pp_loaded_cache = NULL; 
     132        p_bank->b_cache = p_bank->b_cache_dirty = 
     133        p_bank->b_cache_delete = VLC_FALSE; 
     134 
     135        /* Everything worked, attach the object */ 
     136        p_libvlc_global->p_module_bank = p_bank; 
     137        vlc_object_attach( p_bank, p_libvlc_global ); 
     138 
     139        /* Fills the module bank structure with the main module infos. 
     140         * This is very useful as it will allow us to consider the main 
     141         * library just as another module, and for instance the configuration 
     142         * options of main will be available in the module bank structure just 
     143         * as for every other module. */ 
     144        AllocateBuiltinModule( p_this, vlc_entry__main ); 
     145    } 
     146    else 
    128147        p_libvlc_global->p_module_bank->i_usage++; 
    129         vlc_mutex_unlock( lockval.p_address ); 
    130         var_Destroy( p_libvlc_global, "libvlc" ); 
    131         return; 
    132     } 
     148 
    133149    vlc_mutex_unlock( lockval.p_address ); 
    134150    var_Destroy( p_libvlc_global, "libvlc" ); 
    135151 
    136     p_bank = vlc_object_create( p_this, sizeof(module_bank_t) ); 
    137     if( !p_bank ) 
    138         return; 
    139     p_bank->psz_object_name = "module bank"; 
    140     p_bank->i_usage = 1; 
    141     p_bank->i_cache = p_bank->i_loaded_cache = 0; 
    142     p_bank->pp_cache = p_bank->pp_loaded_cache = NULL; 
    143     p_bank->b_cache = p_bank->b_cache_dirty = 
    144         p_bank->b_cache_delete = VLC_FALSE; 
    145  
    146     /* Everything worked, attach the object */ 
    147     p_libvlc_global->p_module_bank = p_bank; 
    148     vlc_object_attach( p_bank, p_libvlc_global ); 
    149  
    150     module_LoadMain( p_this ); 
    151152} 
    152153 
     
    241242    vlc_object_release( p_libvlc_global->p_module_bank ); 
    242243    p_libvlc_global->p_module_bank = NULL; 
    243 } 
    244  
    245 /** 
    246  * Load the main program info into the module bank. 
    247  * 
    248  * Fills the module bank structure with the main module infos. 
    249  * This is very useful as it will allow us to consider the main program just 
    250  * as another module, and for instance the configuration options of main will 
    251  * be available in the module bank structure just as for every other module. 
    252  * \param p_this vlc object structure 
    253  * \return nothing 
    254  */ 
    255 static void module_LoadMain( vlc_object_t *p_this ) 
    256 { 
    257     vlc_value_t lockval; 
    258     libvlc_global_data_t *p_libvlc_global = vlc_global(); 
    259  
    260     var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX ); 
    261     var_Get( p_libvlc_global, "libvlc", &lockval ); 
    262     vlc_mutex_lock( lockval.p_address ); 
    263     if( p_libvlc_global->p_module_bank->b_main ) 
    264     { 
    265         vlc_mutex_unlock( lockval.p_address ); 
    266         var_Destroy( p_libvlc_global, "libvlc" ); 
    267         return; 
    268     } 
    269     p_libvlc_global->p_module_bank->b_main = VLC_TRUE; 
    270     vlc_mutex_unlock( lockval.p_address ); 
    271     var_Destroy( p_libvlc_global, "libvlc" ); 
    272  
    273     AllocateBuiltinModule( p_this, vlc_entry__main ); 
    274244} 
    275245 
  • src/modules/modules.h

    r1f253f8 r30267d3  
    4444    int              i_usage; 
    4545 
    46     vlc_bool_t       b_main; 
    4746    vlc_bool_t       b_builtins; 
    4847    vlc_bool_t       b_plugins;