Alexandre Julliard : server: Store the wait structure in the wait entry and add an accessor function for the thread .
Alexandre Julliard
julliard at winehq.org
Wed Aug 28 14:03:08 CDT 2013
Module: wine
Branch: master
Commit: de9f5b33b8fb505119eb2b5f1af20dc57ae0a3c0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=de9f5b33b8fb505119eb2b5f1af20dc57ae0a3c0
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Aug 22 16:17:54 2013 +0200
server: Store the wait structure in the wait entry and add an accessor function for the thread.
---
server/object.h | 6 +++---
server/queue.c | 6 +++---
server/thread.c | 9 +++++++--
server/thread.h | 1 +
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/server/object.h b/server/object.h
index 3b401bc..50c279f 100644
--- a/server/object.h
+++ b/server/object.h
@@ -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 */
diff --git a/server/queue.c b/server/queue.c
index 7aa9b14..0a02798 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -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;
diff --git a/server/thread.c b/server/thread.c
index b5698b3..38a6219 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -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;
diff --git a/server/thread.h b/server/thread.h
index 1c4a74a..c82f780 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -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 );
More information about the wine-cvs
mailing list