Commit 8f706a4c authored by Philipp Schafft's avatar Philipp Schafft 🦁

Cleanup: Moved config re-read function into right place

Renamed event_config_read() into config_reread_config() and moved
it into cfgfile.c. This allowed to delete event.[ch].
event.[ch] will later be used to implement <event>.
parent 2eb04ccd
......@@ -10,14 +10,14 @@ INCLUDES = -I./common/
noinst_HEADERS = admin.h cfgfile.h logging.h sighandler.h connection.h \
global.h util.h slave.h source.h stats.h refbuf.h client.h \
compat.h fserve.h xslt.h yp.h event.h md5.h \
compat.h fserve.h xslt.h yp.h md5.h \
acl.h auth.h auth_htpasswd.h auth_url.h auth_anonymous.h auth_static.h \
format.h format_ogg.h format_mp3.h format_ebml.h \
format_vorbis.h format_theora.h format_flac.h format_speex.h format_midi.h \
format_kate.h format_skeleton.h format_opus.h
icecast_SOURCES = cfgfile.c main.c logging.c sighandler.c connection.c global.c \
util.c slave.c source.c stats.c refbuf.c client.c \
xslt.c fserve.c event.c admin.c md5.c \
xslt.c fserve.c admin.c md5.c \
format.c format_ogg.c format_mp3.c format_midi.c format_flac.c format_ebml.c \
acl.c auth.c auth_htpasswd.c auth_anonymous.c auth_static.c format_kate.c format_skeleton.c format_opus.c
EXTRA_icecast_SOURCES = yp.c \
......
......@@ -29,7 +29,6 @@
#include "client.h"
#include "source.h"
#include "global.h"
#include "event.h"
#include "stats.h"
#include "compat.h"
#include "xslt.h"
......
......@@ -34,6 +34,11 @@
#include "util.h"
#include "auth.h"
/* for config_reread_config() */
#include "yp.h"
#include "fserve.h"
#include "stats.h"
#define CATMODULE "CONFIG"
#define CONFIG_DEFAULT_LOCATION "Earth"
#define CONFIG_DEFAULT_ADMIN "icemaster@localhost"
......@@ -440,6 +445,47 @@ void config_clear(ice_config_t *c)
memset(c, 0, sizeof(ice_config_t));
}
void config_reread_config(void) {
int ret;
ice_config_t *config;
ice_config_t new_config;
/* reread config file */
config = config_grab_config(); /* Both to get the lock, and to be able
to find out the config filename */
xmlSetGenericErrorFunc("config", log_parse_failure);
ret = config_parse_file(config->config_filename, &new_config);
if(ret < 0) {
ICECAST_LOG_ERROR("Error parsing config, not replacing existing config");
switch (ret) {
case CONFIG_EINSANE:
ICECAST_LOG_ERROR("Config filename null or blank");
break;
case CONFIG_ENOROOT:
ICECAST_LOG_ERROR("Root element not found in %s", config->config_filename);
break;
case CONFIG_EBADROOT:
ICECAST_LOG_ERROR("Not an icecast2 config file: %s",
config->config_filename);
break;
default:
ICECAST_LOG_ERROR("Parse error in reading %s", config->config_filename);
break;
}
config_release_config();
} else {
config_clear(config);
config_set_config(&new_config);
config = config_get_config_unlocked();
restart_logging (config);
yp_recheck_config (config);
fserve_recheck_mime_types (config);
stats_global (config);
config_release_config();
slave_update_all_mounts();
}
}
int config_initial_parse_file(const char *filename)
{
/* Since we're already pointing at it, we don't need to copy it in place */
......
......@@ -216,6 +216,7 @@ typedef struct {
void config_initialize(void);
void config_shutdown(void);
void config_reread_config(void);
int config_parse_file(const char *filename, ice_config_t *configuration);
int config_initial_parse_file(const char *filename);
int config_parse_cmdline(int arg, char **argv);
......
......@@ -60,7 +60,6 @@
#include "source.h"
#include "format.h"
#include "format_mp3.h"
#include "event.h"
#include "admin.h"
#include "auth.h"
......
/* Icecast
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
* Michael Smith <msmith@xiph.org>,
* oddsock <oddsock@xiph.org>,
* Karl Heyes <karl@xiph.org>
* and others (see AUTHORS for details).
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "event.h"
#include "cfgfile.h"
#include "yp.h"
#include "source.h"
#include "refbuf.h"
#include "client.h"
#include "logging.h"
#include "slave.h"
#include "fserve.h"
#include "stats.h"
#define CATMODULE "event"
void event_config_read(void *arg)
{
int ret;
ice_config_t *config;
ice_config_t new_config;
/* reread config file */
config = config_grab_config(); /* Both to get the lock, and to be able
to find out the config filename */
xmlSetGenericErrorFunc ("config", log_parse_failure);
ret = config_parse_file(config->config_filename, &new_config);
if(ret < 0) {
ICECAST_LOG_ERROR("Error parsing config, not replacing existing config");
switch(ret) {
case CONFIG_EINSANE:
ICECAST_LOG_ERROR("Config filename null or blank");
break;
case CONFIG_ENOROOT:
ICECAST_LOG_ERROR("Root element not found in %s", config->config_filename);
break;
case CONFIG_EBADROOT:
ICECAST_LOG_ERROR("Not an icecast2 config file: %s",
config->config_filename);
break;
default:
ICECAST_LOG_ERROR("Parse error in reading %s", config->config_filename);
break;
}
config_release_config();
}
else {
config_clear(config);
config_set_config(&new_config);
config = config_get_config_unlocked();
restart_logging (config);
yp_recheck_config (config);
fserve_recheck_mime_types (config);
stats_global (config);
config_release_config();
slave_update_all_mounts();
}
}
/* Icecast
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
* Michael Smith <msmith@xiph.org>,
* oddsock <oddsock@xiph.org>,
* Karl Heyes <karl@xiph.org>
* and others (see AUTHORS for details).
*/
#ifndef __EVENT_H__
#define __EVENT_H__
#define EVENT_NO_EVENT 0
#define EVENT_CONFIG_READ 1
void event_config_read(void *nothing);
#endif /* __EVENT_H__ */
......@@ -26,7 +26,6 @@
#include "refbuf.h"
#include "client.h"
#include "logging.h"
#include "event.h"
#define CATMODULE "sighandler"
......
......@@ -55,7 +55,6 @@
#include "logging.h"
#include "source.h"
#include "format.h"
#include "event.h"
#define CATMODULE "slave"
......@@ -744,9 +743,8 @@ static void *_slave_thread(void *arg)
/* re-read xml file if requested */
global_lock();
if (global . schedule_config_reread)
{
event_config_read (NULL);
if (global.schedule_config_reread) {
config_reread_config();
global.schedule_config_reread = 0;
}
global_unlock();
......
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