[xiph-cvs] cvs commit: thread thread.c thread.h
Michael Smith
msmith at xiph.org
Fri Aug 9 20:22:44 PDT 2002
msmith 02/08/09 23:22:44
Modified: src config.c connection.c slave.c stats.c
. log.c
. thread.c thread.h
Log:
Various cleanups
Revision Changes Path
1.15 +4 -0 icecast/src/config.c
Index: config.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- config.c 9 Aug 2002 15:03:32 -0000 1.14
+++ config.c 10 Aug 2002 03:22:44 -0000 1.15
@@ -103,6 +103,7 @@
_config_filename = (char *)strdup(filename);
+ xmlInitParser();
doc = xmlParseFile(_config_filename);
if (doc == NULL) {
return CONFIG_EPARSE;
@@ -111,17 +112,20 @@
node = xmlDocGetRootElement(doc);
if (node == NULL) {
xmlFreeDoc(doc);
+ xmlCleanupParser();
return CONFIG_ENOROOT;
}
if (strcmp(node->name, "icecast") != 0) {
xmlFreeDoc(doc);
+ xmlCleanupParser();
return CONFIG_EBADROOT;
}
_parse_root(doc, node->xmlChildrenNode);
xmlFreeDoc(doc);
+ xmlCleanupParser();
return 0;
}
<p><p>1.17 +9 -8 icecast/src/connection.c
Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- connection.c 9 Aug 2002 14:15:08 -0000 1.16
+++ connection.c 10 Aug 2002 03:22:44 -0000 1.17
@@ -45,7 +45,7 @@
} con_queue_t;
typedef struct _thread_queue_tag {
- long thread_id;
+ thread_t *thread_id;
struct _thread_queue_tag *next;
} thread_queue_t;
@@ -158,7 +158,7 @@
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 */
thread_queue_t *item = (thread_queue_t *)malloc(sizeof(thread_queue_t));
@@ -176,9 +176,9 @@
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_mutex_lock(&_queue_mutex);
@@ -186,7 +186,7 @@
item = *queue;
if (item == NULL) {
thread_mutex_unlock(&_queue_mutex);
- return -1;
+ return NULL;
}
*queue = item->next;
@@ -202,7 +202,8 @@
static void _build_pool(void)
{
ice_config_t *config;
- int i, tid;
+ int i;
+ thread_t *tid;
char buff[64];
config = config_get_config();
@@ -216,14 +217,14 @@
static void _destroy_pool(void)
{
- long id;
+ thread_t *id;
int i;
i = 0;
thread_cond_broadcast(&_pool_cond);
id = _pop_thread(&_conhands);
- while (id != -1) {
+ while (id != NULL) {
thread_join(id);
_signal_pool();
id = _pop_thread(&_conhands);
<p><p>1.3 +1 -1 icecast/src/slave.c
Index: slave.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/slave.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- slave.c 9 Aug 2002 08:06:00 -0000 1.2
+++ slave.c 10 Aug 2002 03:22:44 -0000 1.3
@@ -45,7 +45,7 @@
#define CATMODULE "slave"
static void *_slave_thread(void *arg);
-long _slave_thread_id;
+thread_t *_slave_thread_id;
static int _initialized = 0;
void slave_initialize(void) {
<p><p>1.20 +1 -1 icecast/src/stats.c
Index: stats.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/stats.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- stats.c 9 Aug 2002 15:04:40 -0000 1.19
+++ stats.c 10 Aug 2002 03:22:44 -0000 1.20
@@ -33,7 +33,7 @@
} event_listener_t;
int _stats_running = 0;
-long _stats_thread_id;
+thread_t *_stats_thread_id;
int _stats_threads = 0;
stats_t _stats;
<p><p>1.9 +4 -0 log/log.c
Index: log.c
===================================================================
RCS file: /usr/local/cvsroot/log/log.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- log.c 3 Aug 2002 08:14:56 -0000 1.8
+++ log.c 10 Aug 2002 03:22:44 -0000 1.9
@@ -180,7 +180,11 @@
vsnprintf(line, LOG_MAXLINELEN, fmt, ap);
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));
+ _unlock_logger();
snprintf(pre, 256, "%s %s%s", prior[priority-1], cat, func);
<p><p>1.13 +5 -6 thread/thread.c
Index: thread.c
===================================================================
RCS file: /usr/local/cvsroot/thread/thread.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- thread.c 9 Aug 2002 06:52:07 -0000 1.12
+++ thread.c 10 Aug 2002 03:22:44 -0000 1.13
@@ -228,7 +228,7 @@
}
-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;
thread_t *thread;
@@ -259,11 +259,10 @@
if (created == 0) {
LOG_ERROR("System won't let me create more threads, giving up");
- return -1;
+ return NULL;
}
-// return thread->thread_id;
- return thread->sys_thread;
+ return thread;
}
/* _mutex_create
@@ -676,12 +675,12 @@
_mutex_unlock(&_library_mutex);
}
-void thread_join(long thread)
+void thread_join(thread_t *thread)
{
void *ret;
int i;
- i = pthread_join(thread, &ret);
+ i = pthread_join(thread->sys_thread, &ret);
}
/* AVL tree functions */
<p><p>1.6 +2 -2 thread/thread.h
Index: thread.h
===================================================================
RCS file: /usr/local/cvsroot/thread/thread.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- thread.h 5 Aug 2002 14:48:04 -0000 1.5
+++ thread.h 10 Aug 2002 03:22:44 -0000 1.6
@@ -105,7 +105,7 @@
void thread_shutdown(void);
/* 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_lock_c(mutex_t *mutex, int line, char *file);
void thread_mutex_unlock_c(mutex_t *mutex, int line, char *file);
@@ -138,7 +138,7 @@
void thread_rename(const char *name);
/* waits until thread_exit is called for another thread */
-void thread_join(long thread);
+void thread_join(thread_t *thread);
#endif /* __THREAD_H__ */
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list