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;
diff --git a/server/thread.c b/server/thread.c
index 1e2abbd..816f3bf 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -115,7 +115,6 @@
thread->unix_tid = -1; /* not known yet */
thread->context = NULL;
thread->teb = NULL;
- thread->mutex = NULL;
thread->debug_ctx = NULL;
thread->debug_event = NULL;
thread->queue = NULL;
@@ -139,6 +138,7 @@
thread->creation_time = time(NULL);
thread->exit_time = 0;
+ list_init( &thread->mutex_list );
list_init( &thread->system_apc );
list_init( &thread->user_apc );
diff --git a/server/thread.h b/server/thread.h
index 887b8fe..924c471 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -29,7 +29,6 @@
struct process;
struct thread_wait;
struct thread_apc;
-struct mutex;
struct debug_ctx;
struct debug_event;
struct msg_queue;
@@ -57,7 +56,7 @@
struct thread *proc_prev;
struct process *process;
thread_id_t id; /* thread id */
- struct mutex *mutex; /* list of currently owned mutexes */
+ struct list mutex_list; /* list of currently owned mutexes */
struct debug_ctx *debug_ctx; /* debugger context if this thread is a debugger */
struct debug_event *debug_event; /* debug event being sent to debugger */
struct msg_queue *queue; /* message queue */