mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -05:00
Feature: Clear XSLT cache on config reload
This commit is contained in:
parent
3ffe5f4e96
commit
45d44a6349
@ -44,6 +44,7 @@
|
||||
#include "connection.h"
|
||||
#include "main.h"
|
||||
#include "slave.h"
|
||||
#include "xslt.h"
|
||||
|
||||
#define CATMODULE "CONFIG"
|
||||
#define CONFIG_DEFAULT_LOCATION "Earth"
|
||||
@ -748,6 +749,7 @@ void config_reread_config(void)
|
||||
stats_global(config);
|
||||
config_release_config();
|
||||
slave_update_all_mounts();
|
||||
xslt_clear_cache();
|
||||
}
|
||||
}
|
||||
|
||||
|
33
src/xslt.c
33
src/xslt.c
@ -115,14 +115,8 @@ void xslt_initialize(void)
|
||||
}
|
||||
|
||||
void xslt_shutdown(void) {
|
||||
int i;
|
||||
|
||||
for(i=0; i < CACHESIZE; i++) {
|
||||
if(cache[i].filename)
|
||||
free(cache[i].filename);
|
||||
if(cache[i].stylesheet)
|
||||
xsltFreeStylesheet(cache[i].stylesheet);
|
||||
}
|
||||
xslt_clear_cache();
|
||||
|
||||
thread_mutex_destroy (&xsltlock);
|
||||
xmlCleanupParser();
|
||||
@ -131,6 +125,26 @@ void xslt_shutdown(void) {
|
||||
xmlFree(admin_path);
|
||||
}
|
||||
|
||||
static void clear_cache_entry(size_t idx) {
|
||||
free(cache[idx].filename);
|
||||
if (cache[idx].stylesheet)
|
||||
xsltFreeStylesheet(cache[idx].stylesheet);
|
||||
}
|
||||
|
||||
void xslt_clear_cache(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
ICECAST_LOG_DEBUG("Clearing stylesheet cache.");
|
||||
|
||||
thread_mutex_lock(&xsltlock);
|
||||
|
||||
for (i = 0; i < CACHESIZE; i++)
|
||||
clear_cache_entry(i);
|
||||
|
||||
thread_mutex_unlock(&xsltlock);
|
||||
}
|
||||
|
||||
static int evict_cache_entry(void) {
|
||||
int i, age=0, oldest=0;
|
||||
|
||||
@ -141,8 +155,7 @@ static int evict_cache_entry(void) {
|
||||
}
|
||||
}
|
||||
|
||||
xsltFreeStylesheet(cache[oldest].stylesheet);
|
||||
free(cache[oldest].filename);
|
||||
clear_cache_entry(oldest);
|
||||
|
||||
return oldest;
|
||||
}
|
||||
@ -282,9 +295,11 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
|
||||
|
||||
/* Get the actual xmlDoc */
|
||||
if (final_URI) {
|
||||
ICECAST_LOG_DEBUG("Calling xslt_loader() for \"%s\" (was: \"%s\").", final_URI, URI);
|
||||
ret = xslt_loader(final_URI, dict, options, ctxt, type);
|
||||
xmlFree(final_URI);
|
||||
} else {
|
||||
ICECAST_LOG_DEBUG("Calling xslt_loader() for \"%s\".", URI);
|
||||
ret = xslt_loader(URI, dict, options, ctxt, type);
|
||||
}
|
||||
return ret;
|
||||
|
@ -19,4 +19,5 @@
|
||||
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, int status);
|
||||
void xslt_initialize(void);
|
||||
void xslt_shutdown(void);
|
||||
void xslt_clear_cache(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user