[vlc-devel] commit: *Partially* fix the module bank initialization serialization ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Mar 30 16:14:39 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Sun Mar 30 17:02:23 2008 +0300| [30267d389073ee38e29728d0246ef5106e9e1f1a]
*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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=30267d389073ee38e29728d0246ef5106e9e1f1a
---
src/modules/modules.c | 76 +++++++++++++++----------------------------------
src/modules/modules.h | 1 -
2 files changed, 23 insertions(+), 54 deletions(-)
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 2892b2c..87500c4 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -104,8 +104,6 @@ static void DupModule ( module_t * );
static void UndupModule ( module_t * );
#endif
-static void module_LoadMain( vlc_object_t *p_this );
-
/**
* Init bank
*
@@ -123,31 +121,34 @@ void __module_InitBank( vlc_object_t *p_this )
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
- if( p_libvlc_global->p_module_bank )
+
+ if( p_libvlc_global->p_module_bank == NULL )
{
- p_libvlc_global->p_module_bank->i_usage++;
- vlc_mutex_unlock( lockval.p_address );
- var_Destroy( p_libvlc_global, "libvlc" );
- return;
+ p_bank = vlc_object_create( p_this, sizeof(module_bank_t) );
+ p_bank->psz_object_name = "module bank";
+ p_bank->i_usage = 1;
+ p_bank->i_cache = p_bank->i_loaded_cache = 0;
+ p_bank->pp_cache = p_bank->pp_loaded_cache = NULL;
+ p_bank->b_cache = p_bank->b_cache_dirty =
+ p_bank->b_cache_delete = VLC_FALSE;
+
+ /* Everything worked, attach the object */
+ p_libvlc_global->p_module_bank = p_bank;
+ vlc_object_attach( p_bank, p_libvlc_global );
+
+ /* Fills the module bank structure with the main module infos.
+ * This is very useful as it will allow us to consider the main
+ * library just as another module, and for instance the configuration
+ * options of main will be available in the module bank structure just
+ * as for every other module. */
+ AllocateBuiltinModule( p_this, vlc_entry__main );
}
+ else
+ p_libvlc_global->p_module_bank->i_usage++;
+
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_libvlc_global, "libvlc" );
- p_bank = vlc_object_create( p_this, sizeof(module_bank_t) );
- if( !p_bank )
- return;
- p_bank->psz_object_name = "module bank";
- p_bank->i_usage = 1;
- p_bank->i_cache = p_bank->i_loaded_cache = 0;
- p_bank->pp_cache = p_bank->pp_loaded_cache = NULL;
- p_bank->b_cache = p_bank->b_cache_dirty =
- p_bank->b_cache_delete = VLC_FALSE;
-
- /* Everything worked, attach the object */
- p_libvlc_global->p_module_bank = p_bank;
- vlc_object_attach( p_bank, p_libvlc_global );
-
- module_LoadMain( p_this );
}
@@ -243,37 +244,6 @@ void __module_EndBank( vlc_object_t *p_this )
}
/**
- * Load the main program info into the module bank.
- *
- * Fills the module bank structure with the main module infos.
- * This is very useful as it will allow us to consider the main program just
- * as another module, and for instance the configuration options of main will
- * be available in the module bank structure just as for every other module.
- * \param p_this vlc object structure
- * \return nothing
- */
-static void module_LoadMain( vlc_object_t *p_this )
-{
- vlc_value_t lockval;
- libvlc_global_data_t *p_libvlc_global = vlc_global();
-
- var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
- var_Get( p_libvlc_global, "libvlc", &lockval );
- vlc_mutex_lock( lockval.p_address );
- if( p_libvlc_global->p_module_bank->b_main )
- {
- vlc_mutex_unlock( lockval.p_address );
- var_Destroy( p_libvlc_global, "libvlc" );
- return;
- }
- p_libvlc_global->p_module_bank->b_main = VLC_TRUE;
- vlc_mutex_unlock( lockval.p_address );
- var_Destroy( p_libvlc_global, "libvlc" );
-
- AllocateBuiltinModule( p_this, vlc_entry__main );
-}
-
-/**
* Load all modules which we built with.
*
* Fills the module bank structure with the builtin modules.
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 0d2ab31..a8077d9 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -43,7 +43,6 @@ struct module_bank_t
int i_usage;
- vlc_bool_t b_main;
vlc_bool_t b_builtins;
vlc_bool_t b_plugins;
More information about the vlc-devel
mailing list