Convert the per-thread mutex list to a standard list.
diff --git a/server/mutex.c b/server/mutex.c
index af13dd9..1b1ef37 100644
--- a/server/mutex.c
+++ b/server/mutex.c
@@ -37,8 +37,7 @@
struct thread *owner; /* mutex owner */
unsigned int count; /* recursion count */
int abandoned; /* has it been abandoned? */
- struct mutex *next;
- struct mutex *prev;
+ struct list entry; /* entry in owner thread mutex list */
};
static void mutex_dump( struct object *obj, int verbose );
@@ -71,7 +70,6 @@
mutex->count = 0;
mutex->owner = NULL;
mutex->abandoned = 0;
- mutex->next = mutex->prev = NULL;
if (owned) mutex_satisfied( &mutex->obj, current );
}
}
@@ -83,19 +81,18 @@
{
assert( !mutex->count );
/* remove the mutex from the thread list of owned mutexes */
- if (mutex->next) mutex->next->prev = mutex->prev;
- if (mutex->prev) mutex->prev->next = mutex->next;
- else mutex->owner->mutex = mutex->next;
+ list_remove( &mutex->entry );
mutex->owner = NULL;
- mutex->next = mutex->prev = NULL;
wake_up( &mutex->obj, 0 );
}
void abandon_mutexes( struct thread *thread )
{
- while (thread->mutex)
+ struct list *ptr;
+
+ while ((ptr = list_head( &thread->mutex_list )) != NULL)
{
- struct mutex *mutex = thread->mutex;
+ struct mutex *mutex = LIST_ENTRY( ptr, struct mutex, entry );
assert( mutex->owner == thread );
mutex->count = 0;
mutex->abandoned = 1;
@@ -129,9 +126,7 @@
{
assert( !mutex->owner );
mutex->owner = thread;
- mutex->prev = NULL;
- if ((mutex->next = thread->mutex)) mutex->next->prev = mutex;
- thread->mutex = mutex;
+ list_add_head( &thread->mutex_list, &mutex->entry );
}
if (!mutex->abandoned) return 0;
mutex->abandoned = 0;