1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-09-22 04:15:55 -04:00

Various cleanups

svn path=/trunk/log/; revision=3791
This commit is contained in:
Michael Smith 2002-08-10 03:22:44 +00:00
parent 379cb518d5
commit 30577a1391
3 changed files with 11 additions and 8 deletions

View File

@ -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);

View File

@ -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 */

View File

@ -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__ */