mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-01-03 14:56:34 -05:00
Various cleanups
svn path=/trunk/icecast/; revision=3791
This commit is contained in:
parent
05cbe25b54
commit
5d06975c44
@ -103,6 +103,7 @@ int config_parse_file(const char *filename)
|
|||||||
|
|
||||||
_config_filename = (char *)strdup(filename);
|
_config_filename = (char *)strdup(filename);
|
||||||
|
|
||||||
|
xmlInitParser();
|
||||||
doc = xmlParseFile(_config_filename);
|
doc = xmlParseFile(_config_filename);
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
return CONFIG_EPARSE;
|
return CONFIG_EPARSE;
|
||||||
@ -111,17 +112,20 @@ int config_parse_file(const char *filename)
|
|||||||
node = xmlDocGetRootElement(doc);
|
node = xmlDocGetRootElement(doc);
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
xmlCleanupParser();
|
||||||
return CONFIG_ENOROOT;
|
return CONFIG_ENOROOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(node->name, "icecast") != 0) {
|
if (strcmp(node->name, "icecast") != 0) {
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
xmlCleanupParser();
|
||||||
return CONFIG_EBADROOT;
|
return CONFIG_EBADROOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
_parse_root(doc, node->xmlChildrenNode);
|
_parse_root(doc, node->xmlChildrenNode);
|
||||||
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
xmlCleanupParser();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ typedef struct con_queue_tag {
|
|||||||
} con_queue_t;
|
} con_queue_t;
|
||||||
|
|
||||||
typedef struct _thread_queue_tag {
|
typedef struct _thread_queue_tag {
|
||||||
long thread_id;
|
thread_t *thread_id;
|
||||||
struct _thread_queue_tag *next;
|
struct _thread_queue_tag *next;
|
||||||
} thread_queue_t;
|
} thread_queue_t;
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ static void _signal_pool(void)
|
|||||||
thread_cond_signal(&_pool_cond);
|
thread_cond_signal(&_pool_cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _push_thread(thread_queue_t **queue, long thread_id)
|
static void _push_thread(thread_queue_t **queue, thread_t *thread_id)
|
||||||
{
|
{
|
||||||
/* create item */
|
/* create item */
|
||||||
thread_queue_t *item = (thread_queue_t *)malloc(sizeof(thread_queue_t));
|
thread_queue_t *item = (thread_queue_t *)malloc(sizeof(thread_queue_t));
|
||||||
@ -176,9 +176,9 @@ static void _push_thread(thread_queue_t **queue, long thread_id)
|
|||||||
thread_mutex_unlock(&_queue_mutex);
|
thread_mutex_unlock(&_queue_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static long _pop_thread(thread_queue_t **queue)
|
static thread_t *_pop_thread(thread_queue_t **queue)
|
||||||
{
|
{
|
||||||
long id;
|
thread_t *id;
|
||||||
thread_queue_t *item;
|
thread_queue_t *item;
|
||||||
|
|
||||||
thread_mutex_lock(&_queue_mutex);
|
thread_mutex_lock(&_queue_mutex);
|
||||||
@ -186,7 +186,7 @@ static long _pop_thread(thread_queue_t **queue)
|
|||||||
item = *queue;
|
item = *queue;
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
thread_mutex_unlock(&_queue_mutex);
|
thread_mutex_unlock(&_queue_mutex);
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*queue = item->next;
|
*queue = item->next;
|
||||||
@ -202,7 +202,8 @@ static long _pop_thread(thread_queue_t **queue)
|
|||||||
static void _build_pool(void)
|
static void _build_pool(void)
|
||||||
{
|
{
|
||||||
ice_config_t *config;
|
ice_config_t *config;
|
||||||
int i, tid;
|
int i;
|
||||||
|
thread_t *tid;
|
||||||
char buff[64];
|
char buff[64];
|
||||||
|
|
||||||
config = config_get_config();
|
config = config_get_config();
|
||||||
@ -216,14 +217,14 @@ static void _build_pool(void)
|
|||||||
|
|
||||||
static void _destroy_pool(void)
|
static void _destroy_pool(void)
|
||||||
{
|
{
|
||||||
long id;
|
thread_t *id;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
thread_cond_broadcast(&_pool_cond);
|
thread_cond_broadcast(&_pool_cond);
|
||||||
id = _pop_thread(&_conhands);
|
id = _pop_thread(&_conhands);
|
||||||
while (id != -1) {
|
while (id != NULL) {
|
||||||
thread_join(id);
|
thread_join(id);
|
||||||
_signal_pool();
|
_signal_pool();
|
||||||
id = _pop_thread(&_conhands);
|
id = _pop_thread(&_conhands);
|
||||||
|
@ -180,7 +180,11 @@ void log_write(int log_id, int priority, const char *cat, const char *func,
|
|||||||
vsnprintf(line, LOG_MAXLINELEN, fmt, ap);
|
vsnprintf(line, LOG_MAXLINELEN, fmt, ap);
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
|
||||||
|
/* localtime() isn't threadsafe, localtime_r isn't portable enough... */
|
||||||
|
_lock_logger();
|
||||||
strftime(tyme, 128, "[%Y-%m-%d %H:%M:%S]", localtime(&now));
|
strftime(tyme, 128, "[%Y-%m-%d %H:%M:%S]", localtime(&now));
|
||||||
|
_unlock_logger();
|
||||||
|
|
||||||
snprintf(pre, 256, "%s %s%s", prior[priority-1], cat, func);
|
snprintf(pre, 256, "%s %s%s", prior[priority-1], cat, func);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#define CATMODULE "slave"
|
#define CATMODULE "slave"
|
||||||
|
|
||||||
static void *_slave_thread(void *arg);
|
static void *_slave_thread(void *arg);
|
||||||
long _slave_thread_id;
|
thread_t *_slave_thread_id;
|
||||||
static int _initialized = 0;
|
static int _initialized = 0;
|
||||||
|
|
||||||
void slave_initialize(void) {
|
void slave_initialize(void) {
|
||||||
|
@ -33,7 +33,7 @@ typedef struct _event_listener_tag
|
|||||||
} event_listener_t;
|
} event_listener_t;
|
||||||
|
|
||||||
int _stats_running = 0;
|
int _stats_running = 0;
|
||||||
long _stats_thread_id;
|
thread_t *_stats_thread_id;
|
||||||
int _stats_threads = 0;
|
int _stats_threads = 0;
|
||||||
|
|
||||||
stats_t _stats;
|
stats_t _stats;
|
||||||
|
@ -228,7 +228,7 @@ static void _catch_signals(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int detached, int line, char *file)
|
thread_t *thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int detached, int line, char *file)
|
||||||
{
|
{
|
||||||
int created;
|
int created;
|
||||||
thread_t *thread;
|
thread_t *thread;
|
||||||
@ -259,11 +259,10 @@ long thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int
|
|||||||
|
|
||||||
if (created == 0) {
|
if (created == 0) {
|
||||||
LOG_ERROR("System won't let me create more threads, giving up");
|
LOG_ERROR("System won't let me create more threads, giving up");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return thread->thread_id;
|
return thread;
|
||||||
return thread->sys_thread;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _mutex_create
|
/* _mutex_create
|
||||||
@ -676,12 +675,12 @@ void thread_library_unlock(void)
|
|||||||
_mutex_unlock(&_library_mutex);
|
_mutex_unlock(&_library_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void thread_join(long thread)
|
void thread_join(thread_t *thread)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = pthread_join(thread, &ret);
|
i = pthread_join(thread->sys_thread, &ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AVL tree functions */
|
/* AVL tree functions */
|
||||||
|
@ -105,7 +105,7 @@ void thread_initialize_with_log_id(int log_id);
|
|||||||
void thread_shutdown(void);
|
void thread_shutdown(void);
|
||||||
|
|
||||||
/* creation, destruction, locking, unlocking, signalling and waiting */
|
/* creation, destruction, locking, unlocking, signalling and waiting */
|
||||||
long thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int detached, int line, char *file);
|
thread_t *thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int detached, int line, char *file);
|
||||||
void thread_mutex_create_c(mutex_t *mutex, int line, char *file);
|
void thread_mutex_create_c(mutex_t *mutex, int line, char *file);
|
||||||
void thread_mutex_lock_c(mutex_t *mutex, int line, char *file);
|
void thread_mutex_lock_c(mutex_t *mutex, int line, char *file);
|
||||||
void thread_mutex_unlock_c(mutex_t *mutex, int line, char *file);
|
void thread_mutex_unlock_c(mutex_t *mutex, int line, char *file);
|
||||||
@ -138,7 +138,7 @@ thread_t *thread_self(void);
|
|||||||
void thread_rename(const char *name);
|
void thread_rename(const char *name);
|
||||||
|
|
||||||
/* waits until thread_exit is called for another thread */
|
/* waits until thread_exit is called for another thread */
|
||||||
void thread_join(long thread);
|
void thread_join(thread_t *thread);
|
||||||
|
|
||||||
#endif /* __THREAD_H__ */
|
#endif /* __THREAD_H__ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user