event.c 1.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/* 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).
 */

13
14
15
16
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

Michael Smith's avatar
Michael Smith committed
17
#include "event.h"
18
#include "cfgfile.h"
19
#include "yp.h"
Michael Smith's avatar
Michael Smith committed
20
21
22
23

#include "refbuf.h"
#include "client.h"
#include "logging.h"
24
#include "slave.h"
Michael Smith's avatar
Michael Smith committed
25
26
27
28
29
30
31
32

#define CATMODULE "event"

void event_config_read(void *arg)
{
    int ret;
    ice_config_t *config;
    ice_config_t new_config;
33
    /* reread config file */
Michael Smith's avatar
Michael Smith committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

    config = config_get_config(); /* Both to get the lock, and to be able
                                     to find out the config filename */
    ret = config_parse_file(config->config_filename, &new_config);
    if(ret < 0) {
        ERROR0("Error parsing config, not replacing existing config");
        switch(ret) {
            case CONFIG_EINSANE:
                ERROR0("Config filename null or blank");
                break;
            case CONFIG_ENOROOT:
                ERROR1("Root element not found in %s", config->config_filename);
                break;
            case CONFIG_EBADROOT:
                ERROR1("Not an icecast2 config file: %s",
                        config->config_filename);
                break;
            default:
                ERROR1("Parse error in reading %s", config->config_filename);
                break;
        }
        config_release_config();
    }
    else {
        config_clear(config);
        config_set_config(&new_config);
60
        restart_logging (config_get_config_unlocked());
61
        slave_recheck();
62
        yp_recheck_config (config_get_config_unlocked());
Michael Smith's avatar
Michael Smith committed
63
64
65
66
67

        config_release_config();
    }
}