Commit 468d5f4d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Plugins cache entries are one time use things

As the module descriptor is referenced into the main module list
(without copying).
parent 8dbde14e
......@@ -675,17 +675,21 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module )
/*****************************************************************************
* CacheFind: finds the cache entry corresponding to a file
*****************************************************************************/
module_cache_t *CacheFind( module_bank_t *p_bank,
const char *path, time_t mtime, off_t size )
module_t *CacheFind( module_bank_t *p_bank,
const char *path, time_t mtime, off_t size )
{
module_cache_t **cache = p_bank->pp_loaded_cache;
size_t n = p_bank->i_loaded_cache;
for( size_t i = 0; i < n; i++ )
if( !strcmp( cache[i]->path, path )
&& cache[i]->mtime == mtime &&
cache[i]->size == size )
return cache[i];
&& cache[i]->mtime == mtime
&& cache[i]->size == size )
{
module_t *module = cache[i]->p_module;
cache[i]->p_module = NULL;
return module;
}
return NULL;
}
......
......@@ -168,7 +168,8 @@ void module_EndBank( vlc_object_t *p_this, bool b_plugins )
{
if( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] )
{
DeleteModule( p_bank,
if( unlikely( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module != NULL ) )
DeleteModule( p_bank,
p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->path );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] );
......@@ -956,47 +957,36 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
cache_mode_t mode )
{
module_t * p_module = NULL;
module_cache_t *p_cache_entry = NULL;
/*
* Check our plugins cache first then load plugin if needed
*/
//if( mode == CACHE_USE )
p_cache_entry = CacheFind( p_bank, path, mtime, size );
if( p_cache_entry == NULL )
{
p_module = AllocatePlugin( p_this, path );
/* FIXME: VLC_PLUGIN_PATH may contains duplicates or aliases.
* This needs to be handled correctly even if caching is disabled. */
}
else
if( mode == CACHE_USE )
{
module_config_t *p_item = NULL, *p_end = NULL;
p_module = p_cache_entry->p_module;
p_module->b_loaded = false;
/* If VLC_PLUGIN_PATH contains duplicate entries... */
if( p_module->next != NULL )
return 0; /* already taken care of that one */
/* For now we force loading if the module's config contains
* callbacks or actions.
* Could be optimized by adding an API call.*/
for( p_item = p_module->p_config, p_end = p_item + p_module->confsize;
p_item < p_end; p_item++ )
p_module = CacheFind( p_bank, path, mtime, size );
if( p_module != NULL )
{
if( p_item->i_action )
{
p_module = AllocatePlugin( p_this, path );
break;
}
/* For now we force loading if the module's config contains
* callbacks or actions.
* Could be optimized by adding an API call.*/
assert( !p_module->b_loaded );
for( size_t n = p_module->confsize, i = 0; i < n; i++ )
if( p_module->p_config[i].i_action )
{
DeleteModule( p_bank, p_module );
p_module = AllocatePlugin( p_this, path );
break;
}
}
}
if( p_module == NULL )
return -1;
{
p_module = AllocatePlugin( p_this, path );
if( p_module == NULL )
return -1;
}
/* We have not already scanned and inserted this module */
assert( p_module->next == NULL );
......
......@@ -152,6 +152,6 @@ void CacheMerge (vlc_object_t *, module_t *, module_t *);
void CacheDelete(vlc_object_t *, const char *);
void CacheLoad (vlc_object_t *, module_bank_t *, const char *);
void CacheSave (vlc_object_t *, const char *, module_cache_t *const *, size_t);
module_cache_t * CacheFind (module_bank_t *, const char *, time_t, off_t);
module_t * CacheFind (module_bank_t *, const char *, time_t, off_t);
#endif /* !LIBVLC_MODULES_H */
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