Commit d3904369 authored by Marvin Scholz's avatar Marvin Scholz Committed by Philipp Schafft

Cleanup: corrected use of white spaces

parent b182f8df
......@@ -94,7 +94,7 @@ static int _initialized = 0;
static avl_tree *_threadtree = NULL;
#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};
#else
static mutex_t _threadtree_mutex = { PTHREAD_MUTEX_INITIALIZER };
......@@ -159,7 +159,7 @@ void thread_initialize(void)
_mutextree = avl_tree_new(_compare_mutexes, NULL);
/* 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);
......@@ -168,7 +168,7 @@ void thread_initialize(void)
#endif
thread_mutex_create(&_threadtree_mutex);
thread_mutex_create(&_library_mutex);
thread_mutex_create(&_library_mutex);
/* initialize the thread tree and insert the main thread */
......@@ -197,7 +197,7 @@ void thread_shutdown(void)
thread_mutex_destroy(&_threadtree_mutex);
#ifdef THREAD_DEBUG
thread_mutex_destroy(&_mutextree_mutex);
avl_tree_free(_mutextree, _free_mutex);
#endif
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)
{
thread_type *thread = NULL;
thread_start_t *start = NULL;
pthread_attr_t attr;
thread = (thread_type *)calloc(1, sizeof(thread_type));
thread = (thread_type *)calloc(1, sizeof(thread_type));
do {
if (thread == NULL)
break;
......@@ -287,7 +287,7 @@ thread_type *thread_create_c(char *name, void *(*start_routine)(void *),
thread->line = line;
thread->file = strdup(file);
_mutex_lock (&_threadtree_mutex);
_mutex_lock (&_threadtree_mutex);
thread->thread_id = _next_thread_id++;
_mutex_unlock (&_threadtree_mutex);
......@@ -325,7 +325,7 @@ thread_type *thread_create_c(char *name, void *(*start_routine)(void *),
}
/* _mutex_create
**
**
** creates a 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);
node = avl_get_first (_mutextree);
while (node) {
tmutex = (mutex_t *)node->key;
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 */
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);
_mutex_unlock(&_mutextree_mutex);
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) */
locks++;
}
......@@ -404,7 +404,7 @@ void thread_mutex_lock_c(mutex_t *mutex, int line, char *file)
node = avl_get_next(node);
}
if (locks > 0) {
if (locks > 0) {
/* Has already got a mutex locked */
if (_multi_mutex.thread_id != th->thread_id) {
/* 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);
}
}
_mutex_unlock(&_mutextree_mutex);
}
# endif /* CHECK_MUTEXES */
_mutex_lock(mutex);
_mutex_lock(&_mutextree_mutex);
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->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_unlock(&_mutextree_mutex);
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)) {
/* 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!",
_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;
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));
}
......@@ -590,7 +590,7 @@ void thread_exit_c(long val, int line, char *file)
_mutex_unlock(&_mutextree_mutex);
}
#endif
if (th && th->detached)
{
#ifdef THREAD_DEBUG
......@@ -623,7 +623,7 @@ void thread_sleep(unsigned long len)
while (ret != 0 && errno == EINTR) {
time_sleep.tv_sec = time_remaining.tv_sec;
time_sleep.tv_nsec = time_remaining.tv_nsec;
ret = nanosleep(&time_sleep, &time_remaining);
}
# else
......@@ -686,9 +686,9 @@ thread_type *thread_self(void)
_mutex_unlock(&_threadtree_mutex);
return NULL;
}
node = avl_get_first(_threadtree);
while (node) {
th = (thread_type *)node->key;
......@@ -696,7 +696,7 @@ thread_type *thread_self(void)
_mutex_unlock(&_threadtree_mutex);
return th;
}
node = avl_get_next(node);
}
_mutex_unlock(&_threadtree_mutex);
......@@ -705,7 +705,7 @@ thread_type *thread_self(void)
#ifdef THREAD_DEBUG
LOG_ERROR("Nonexistant thread alive...");
#endif
return NULL;
}
......@@ -719,7 +719,7 @@ void thread_rename(const char *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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment