0
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2025-06-30 22:18:29 -04:00

Cleanup: corrected use of white spaces

This commit is contained in:
Marvin Scholz 2016-03-16 11:11:18 +01:00 committed by Philipp Schafft
parent b182f8df1b
commit d3904369e8

View File

@ -94,7 +94,7 @@ static int _initialized = 0;
static avl_tree *_threadtree = NULL; static avl_tree *_threadtree = NULL;
#ifdef DEBUG_MUTEXES #ifdef DEBUG_MUTEXES
static mutex_t _threadtree_mutex = { -1, NULL, MUTEX_STATE_UNINIT, NULL, -1, static mutex_t _threadtree_mutex = { -1, NULL, MUTEX_STATE_UNINIT, NULL, -1,
PTHREAD_MUTEX_INITIALIZER}; PTHREAD_MUTEX_INITIALIZER};
#else #else
static mutex_t _threadtree_mutex = { PTHREAD_MUTEX_INITIALIZER }; static mutex_t _threadtree_mutex = { PTHREAD_MUTEX_INITIALIZER };
@ -159,7 +159,7 @@ void thread_initialize(void)
_mutextree = avl_tree_new(_compare_mutexes, NULL); _mutextree = avl_tree_new(_compare_mutexes, NULL);
/* we have to create this one by hand, because there's no /* we have to create this one by hand, because there's no
** mutextree_mutex to lock yet! ** mutextree_mutex to lock yet!
*/ */
_mutex_create(&_mutextree_mutex); _mutex_create(&_mutextree_mutex);
@ -168,7 +168,7 @@ void thread_initialize(void)
#endif #endif
thread_mutex_create(&_threadtree_mutex); thread_mutex_create(&_threadtree_mutex);
thread_mutex_create(&_library_mutex); thread_mutex_create(&_library_mutex);
/* initialize the thread tree and insert the main thread */ /* initialize the thread tree and insert the main thread */
@ -197,7 +197,7 @@ void thread_shutdown(void)
thread_mutex_destroy(&_threadtree_mutex); thread_mutex_destroy(&_threadtree_mutex);
#ifdef THREAD_DEBUG #ifdef THREAD_DEBUG
thread_mutex_destroy(&_mutextree_mutex); thread_mutex_destroy(&_mutextree_mutex);
avl_tree_free(_mutextree, _free_mutex); avl_tree_free(_mutextree, _free_mutex);
#endif #endif
avl_tree_free(_threadtree, _free_thread); avl_tree_free(_threadtree, _free_thread);
@ -267,14 +267,14 @@ static void _catch_signals(void)
} }
thread_type *thread_create_c(char *name, void *(*start_routine)(void *), thread_type *thread_create_c(char *name, void *(*start_routine)(void *),
void *arg, int detached, int line, char *file) void *arg, int detached, int line, char *file)
{ {
thread_type *thread = NULL; thread_type *thread = NULL;
thread_start_t *start = NULL; thread_start_t *start = NULL;
pthread_attr_t attr; pthread_attr_t attr;
thread = (thread_type *)calloc(1, sizeof(thread_type)); thread = (thread_type *)calloc(1, sizeof(thread_type));
do { do {
if (thread == NULL) if (thread == NULL)
break; break;
@ -287,7 +287,7 @@ thread_type *thread_create_c(char *name, void *(*start_routine)(void *),
thread->line = line; thread->line = line;
thread->file = strdup(file); thread->file = strdup(file);
_mutex_lock (&_threadtree_mutex); _mutex_lock (&_threadtree_mutex);
thread->thread_id = _next_thread_id++; thread->thread_id = _next_thread_id++;
_mutex_unlock (&_threadtree_mutex); _mutex_unlock (&_threadtree_mutex);
@ -325,7 +325,7 @@ thread_type *thread_create_c(char *name, void *(*start_routine)(void *),
} }
/* _mutex_create /* _mutex_create
** **
** creates a mutex ** creates a mutex
*/ */
static void _mutex_create(mutex_t *mutex) static void _mutex_create(mutex_t *mutex)
@ -383,20 +383,20 @@ void thread_mutex_lock_c(mutex_t *mutex, int line, char *file)
_mutex_lock(&_mutextree_mutex); _mutex_lock(&_mutextree_mutex);
node = avl_get_first (_mutextree); node = avl_get_first (_mutextree);
while (node) { while (node) {
tmutex = (mutex_t *)node->key; tmutex = (mutex_t *)node->key;
if (tmutex->mutex_id == mutex->mutex_id) { if (tmutex->mutex_id == mutex->mutex_id) {
if (tmutex->thread_id == th->thread_id) { if (tmutex->thread_id == th->thread_id) {
/* Deadlock, same thread can't lock the same mutex twice */ /* Deadlock, same thread can't lock the same mutex twice */
LOG_ERROR7("DEADLOCK AVOIDED (%d == %d) on mutex [%s] in file %s line %d by thread %d [%s]", LOG_ERROR7("DEADLOCK AVOIDED (%d == %d) on mutex [%s] in file %s line %d by thread %d [%s]",
tmutex->thread_id, th->thread_id, mutex->name ? mutex->name : "undefined", file, line, th->thread_id, th->name); tmutex->thread_id, th->thread_id, mutex->name ? mutex->name : "undefined", file, line, th->thread_id, th->name);
_mutex_unlock(&_mutextree_mutex); _mutex_unlock(&_mutextree_mutex);
return; return;
} }
} else if (tmutex->thread_id == th->thread_id) { } else if (tmutex->thread_id == th->thread_id) {
/* Mutex locked by this thread (not this mutex) */ /* Mutex locked by this thread (not this mutex) */
locks++; locks++;
} }
@ -404,7 +404,7 @@ void thread_mutex_lock_c(mutex_t *mutex, int line, char *file)
node = avl_get_next(node); node = avl_get_next(node);
} }
if (locks > 0) { if (locks > 0) {
/* Has already got a mutex locked */ /* Has already got a mutex locked */
if (_multi_mutex.thread_id != th->thread_id) { if (_multi_mutex.thread_id != th->thread_id) {
/* Tries to lock two mutexes, but has not got the double mutex, norty boy! */ /* Tries to lock two mutexes, but has not got the double mutex, norty boy! */
@ -412,13 +412,13 @@ void thread_mutex_lock_c(mutex_t *mutex, int line, char *file)
_multi_mutex.thread_id, th->thread_id, th->thread_id, th->name, mutex->name ? mutex->name : "undefined", file, line); _multi_mutex.thread_id, th->thread_id, th->thread_id, th->name, mutex->name ? mutex->name : "undefined", file, line);
} }
} }
_mutex_unlock(&_mutextree_mutex); _mutex_unlock(&_mutextree_mutex);
} }
# endif /* CHECK_MUTEXES */ # endif /* CHECK_MUTEXES */
_mutex_lock(mutex); _mutex_lock(mutex);
_mutex_lock(&_mutextree_mutex); _mutex_lock(&_mutextree_mutex);
LOG_DEBUG2("Locked %p by thread %d", mutex, th ? th->thread_id : -1); LOG_DEBUG2("Locked %p by thread %d", mutex, th ? th->thread_id : -1);
@ -459,7 +459,7 @@ void thread_mutex_unlock_c(mutex_t *mutex, int line, char *file)
if (tmutex->mutex_id == mutex->mutex_id) { if (tmutex->mutex_id == mutex->mutex_id) {
if (tmutex->thread_id != th->thread_id) { if (tmutex->thread_id != th->thread_id) {
LOG_ERROR7("ILLEGAL UNLOCK (%d != %d) on mutex [%s] in file %s line %d by thread %d [%s]", tmutex->thread_id, th->thread_id, LOG_ERROR7("ILLEGAL UNLOCK (%d != %d) on mutex [%s] in file %s line %d by thread %d [%s]", tmutex->thread_id, th->thread_id,
mutex->name ? mutex->name : "undefined", file, line, th->thread_id, th->name); mutex->name ? mutex->name : "undefined", file, line, th->thread_id, th->name);
_mutex_unlock(&_mutextree_mutex); _mutex_unlock(&_mutextree_mutex);
return; return;
@ -473,7 +473,7 @@ void thread_mutex_unlock_c(mutex_t *mutex, int line, char *file)
if ((locks > 0) && (_multi_mutex.thread_id != th->thread_id)) { if ((locks > 0) && (_multi_mutex.thread_id != th->thread_id)) {
/* Don't have double mutex, has more than this mutex left */ /* Don't have double mutex, has more than this mutex left */
LOG_WARN("(%d != %d) Thread %d [%s] tries to unlock a mutex [%s] in file %s line %d, without owning double mutex!", LOG_WARN("(%d != %d) Thread %d [%s] tries to unlock a mutex [%s] in file %s line %d, without owning double mutex!",
_multi_mutex.thread_id, th->thread_id, th->thread_id, th->name, mutex->name ? mutex->name : "undefined", file, line); _multi_mutex.thread_id, th->thread_id, th->thread_id, th->name, mutex->name ? mutex->name : "undefined", file, line);
} }
@ -580,7 +580,7 @@ void thread_exit_c(long val, int line, char *file)
tmutex = (mutex_t *)node->key; tmutex = (mutex_t *)node->key;
if (tmutex->thread_id == th->thread_id) { if (tmutex->thread_id == th->thread_id) {
LOG_WARN("Thread %d [%s] exiting in file %s line %d, without unlocking mutex [%s]", LOG_WARN("Thread %d [%s] exiting in file %s line %d, without unlocking mutex [%s]",
th->thread_id, th->name, file, line, mutex_to_string(tmutex, name)); th->thread_id, th->name, file, line, mutex_to_string(tmutex, name));
} }
@ -590,7 +590,7 @@ void thread_exit_c(long val, int line, char *file)
_mutex_unlock(&_mutextree_mutex); _mutex_unlock(&_mutextree_mutex);
} }
#endif #endif
if (th && th->detached) if (th && th->detached)
{ {
#ifdef THREAD_DEBUG #ifdef THREAD_DEBUG
@ -623,7 +623,7 @@ void thread_sleep(unsigned long len)
while (ret != 0 && errno == EINTR) { while (ret != 0 && errno == EINTR) {
time_sleep.tv_sec = time_remaining.tv_sec; time_sleep.tv_sec = time_remaining.tv_sec;
time_sleep.tv_nsec = time_remaining.tv_nsec; time_sleep.tv_nsec = time_remaining.tv_nsec;
ret = nanosleep(&time_sleep, &time_remaining); ret = nanosleep(&time_sleep, &time_remaining);
} }
# else # else
@ -686,9 +686,9 @@ thread_type *thread_self(void)
_mutex_unlock(&_threadtree_mutex); _mutex_unlock(&_threadtree_mutex);
return NULL; return NULL;
} }
node = avl_get_first(_threadtree); node = avl_get_first(_threadtree);
while (node) { while (node) {
th = (thread_type *)node->key; th = (thread_type *)node->key;
@ -696,7 +696,7 @@ thread_type *thread_self(void)
_mutex_unlock(&_threadtree_mutex); _mutex_unlock(&_threadtree_mutex);
return th; return th;
} }
node = avl_get_next(node); node = avl_get_next(node);
} }
_mutex_unlock(&_threadtree_mutex); _mutex_unlock(&_threadtree_mutex);
@ -705,7 +705,7 @@ thread_type *thread_self(void)
#ifdef THREAD_DEBUG #ifdef THREAD_DEBUG
LOG_ERROR("Nonexistant thread alive..."); LOG_ERROR("Nonexistant thread alive...");
#endif #endif
return NULL; return NULL;
} }
@ -719,7 +719,7 @@ void thread_rename(const char *name)
th->name = strdup(name); th->name = strdup(name);
} }
static void _mutex_lock(mutex_t *mutex) static void _mutex_lock(mutex_t *mutex)
{ {
pthread_mutex_lock(&mutex->sys_mutex); pthread_mutex_lock(&mutex->sys_mutex);
} }