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