Commit 1661fa70 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Pass struct stat pointer when looking up a plugin in the cache

parent 7cc97eda
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
...@@ -632,19 +633,19 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module ) ...@@ -632,19 +633,19 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module )
p_module->b_loaded = false; p_module->b_loaded = false;
} }
/***************************************************************************** /**
* CacheFind: finds the cache entry corresponding to a file * Looks up a plugin file in a list of cached plugins.
*****************************************************************************/ */
module_t *CacheFind( module_bank_t *p_bank, module_t *CacheFind (module_bank_t *p_bank,
const char *path, time_t mtime, off_t size ) const char *path, const struct stat *st)
{ {
module_cache_t **cache = p_bank->pp_loaded_cache; module_cache_t **cache = p_bank->pp_loaded_cache;
size_t n = p_bank->i_loaded_cache; size_t n = p_bank->i_loaded_cache;
for( size_t i = 0; i < n; i++ ) for( size_t i = 0; i < n; i++ )
if( !strcmp( cache[i]->path, path ) if( !strcmp( cache[i]->path, path )
&& cache[i]->mtime == mtime && cache[i]->mtime == st->st_mtime
&& cache[i]->size == size ) && cache[i]->size == st->st_size)
{ {
module_t *module = cache[i]->p_module; module_t *module = cache[i]->p_module;
cache[i]->p_module = NULL; cache[i]->p_module = NULL;
......
...@@ -74,7 +74,7 @@ static void AllocatePluginPath( vlc_object_t *, module_bank_t *, const char *, ...@@ -74,7 +74,7 @@ static void AllocatePluginPath( vlc_object_t *, module_bank_t *, const char *,
static void AllocatePluginDir( vlc_object_t *, module_bank_t *, const char *, static void AllocatePluginDir( vlc_object_t *, module_bank_t *, const char *,
unsigned, cache_mode_t ); unsigned, cache_mode_t );
static int AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *, static int AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *,
time_t, off_t, cache_mode_t ); const struct stat *, cache_mode_t );
static module_t * AllocatePlugin( vlc_object_t *, const char *, bool ); static module_t * AllocatePlugin( vlc_object_t *, const char *, bool );
#endif #endif
static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) ); static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) );
...@@ -945,8 +945,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, module_bank_t *p_bank, ...@@ -945,8 +945,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, module_bank_t *p_bank,
&& !strncasecmp (path + pathlen - strlen ("_plugin"LIBEXT), && !strncasecmp (path + pathlen - strlen ("_plugin"LIBEXT),
"_plugin"LIBEXT, strlen ("_plugni"LIBEXT))) "_plugin"LIBEXT, strlen ("_plugni"LIBEXT)))
/* ^^ We only load files matching "lib*_plugin"LIBEXT */ /* ^^ We only load files matching "lib*_plugin"LIBEXT */
AllocatePluginFile (p_this, p_bank, path, st.st_mtime, st.st_size, AllocatePluginFile (p_this, p_bank, path, &st, mode);
mode);
free (path); free (path);
} }
...@@ -961,7 +960,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, module_bank_t *p_bank, ...@@ -961,7 +960,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, module_bank_t *p_bank,
* and module_unneed. It can be removed by DeleteModule. * and module_unneed. It can be removed by DeleteModule.
*****************************************************************************/ *****************************************************************************/
static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
const char *path, time_t mtime, off_t size, const char *path, const struct stat *st,
cache_mode_t mode ) cache_mode_t mode )
{ {
module_t * p_module = NULL; module_t * p_module = NULL;
...@@ -970,7 +969,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -970,7 +969,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
p_module->psz_object_name, p_module->psz_longname ); */ p_module->psz_object_name, p_module->psz_longname ); */
/* Check our plugins cache first then load plugin if needed */ /* Check our plugins cache first then load plugin if needed */
if( mode == CACHE_USE ) if( mode == CACHE_USE )
p_module = CacheFind( p_bank, path, mtime, size ); p_module = CacheFind( p_bank, path, st );
if( p_module == NULL ) if( p_module == NULL )
p_module = AllocatePlugin( p_this, path, true ); p_module = AllocatePlugin( p_this, path, true );
if( p_module == NULL ) if( p_module == NULL )
...@@ -1016,8 +1015,8 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -1016,8 +1015,8 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
if( pp_cache[p_bank->i_cache] == NULL ) if( pp_cache[p_bank->i_cache] == NULL )
return -1; return -1;
pp_cache[p_bank->i_cache]->path = strdup( path ); pp_cache[p_bank->i_cache]->path = strdup( path );
pp_cache[p_bank->i_cache]->mtime = mtime; pp_cache[p_bank->i_cache]->mtime = st->st_mtime;
pp_cache[p_bank->i_cache]->size = size; pp_cache[p_bank->i_cache]->size = st->st_size;
pp_cache[p_bank->i_cache]->p_module = p_module; pp_cache[p_bank->i_cache]->p_module = p_module;
p_bank->pp_cache = pp_cache; p_bank->pp_cache = pp_cache;
p_bank->i_cache++; p_bank->i_cache++;
......
...@@ -150,6 +150,6 @@ void CacheMerge (vlc_object_t *, module_t *, module_t *); ...@@ -150,6 +150,6 @@ void CacheMerge (vlc_object_t *, module_t *, module_t *);
void CacheDelete(vlc_object_t *, const char *); void CacheDelete(vlc_object_t *, const char *);
size_t CacheLoad (vlc_object_t *, const char *, module_cache_t ***); size_t CacheLoad (vlc_object_t *, const char *, module_cache_t ***);
void CacheSave (vlc_object_t *, const char *, module_cache_t *const *, size_t); void CacheSave (vlc_object_t *, const char *, module_cache_t *const *, size_t);
module_t * CacheFind (module_bank_t *, const char *, time_t, off_t); module_t * CacheFind (module_bank_t *, const char *, const struct stat *);
#endif /* !LIBVLC_MODULES_H */ #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