Commit de9f5b33 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Store the wait structure in the wait entry and add an accessor function for the thread.

parent d21b05b0
......@@ -106,9 +106,9 @@ struct object
struct wait_queue_entry
{
struct list entry;
struct object *obj;
struct thread *thread;
struct list entry;
struct object *obj;
struct thread_wait *wait;
};
extern void *mem_alloc( size_t size ); /* malloc wrapper */
......
......@@ -866,7 +866,7 @@ static int is_queue_hung( struct msg_queue *queue )
LIST_FOR_EACH_ENTRY( entry, &queue->obj.wait_queue, struct wait_queue_entry, entry )
{
if (entry->thread->queue == queue)
if (get_wait_queue_thread(entry)->queue == queue)
return 0; /* thread is waiting on queue -> not hung */
}
return 1;
......@@ -875,10 +875,10 @@ static int is_queue_hung( struct msg_queue *queue )
static int msg_queue_add_queue( struct object *obj, struct wait_queue_entry *entry )
{
struct msg_queue *queue = (struct msg_queue *)obj;
struct process *process = entry->thread->process;
struct process *process = get_wait_queue_thread(entry)->process;
/* a thread can only wait on its own queue */
if (entry->thread->queue != queue)
if (get_wait_queue_thread(entry)->queue != queue)
{
set_error( STATUS_ACCESS_DENIED );
return 0;
......
......@@ -543,6 +543,11 @@ void remove_queue( struct object *obj, struct wait_queue_entry *entry )
release_object( obj );
}
struct thread *get_wait_queue_thread( struct wait_queue_entry *entry )
{
return entry->wait->thread;
}
/* finish waiting */
static void end_wait( struct thread *thread )
{
......@@ -579,7 +584,7 @@ static int wait_on( const select_op_t *select_op, unsigned int count, struct obj
for (i = 0, entry = wait->queues; i < count; i++, entry++)
{
struct object *obj = objects[i];
entry->thread = current;
entry->wait = wait;
if (!obj->ops->add_queue( obj, entry ))
{
wait->count = i;
......@@ -809,7 +814,7 @@ void wake_up( struct object *obj, int max )
LIST_FOR_EACH( ptr, &obj->wait_queue )
{
struct wait_queue_entry *entry = LIST_ENTRY( ptr, struct wait_queue_entry, entry );
if (!wake_thread( entry->thread )) continue;
if (!wake_thread( get_wait_queue_thread( entry ))) continue;
if (max && !--max) break;
/* restart at the head of the list since a wake up can change the object wait queue */
ptr = &obj->wait_queue;
......
......@@ -105,6 +105,7 @@ extern struct thread *get_thread_from_id( thread_id_t id );
extern struct thread *get_thread_from_handle( obj_handle_t handle, unsigned int access );
extern struct thread *get_thread_from_tid( int tid );
extern struct thread *get_thread_from_pid( int pid );
extern struct thread *get_wait_queue_thread( struct wait_queue_entry *entry );
extern void stop_thread( struct thread *thread );
extern void stop_thread_if_suspended( struct thread *thread );
extern int wake_thread( struct thread *thread );
......
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