server: Move thread message queue masks to the shared mapping.

This commit is contained in:
Rémi Bernon 2024-02-19 22:40:56 +01:00 committed by Alexandre Julliard
parent ce4674e180
commit faa10ba7b5
3 changed files with 51 additions and 15 deletions

View file

@ -900,6 +900,8 @@ typedef volatile struct
typedef volatile struct
{
int hooks_count[WH_MAX - WH_MIN + 2];
unsigned int wake_mask;
unsigned int changed_mask;
} queue_shm_t;
typedef volatile union
@ -6587,7 +6589,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 819
#define SERVER_PROTOCOL_VERSION 820
/* ### protocol_version end ### */

View file

@ -916,6 +916,8 @@ typedef volatile struct
typedef volatile struct
{
int hooks_count[WH_MAX - WH_MIN + 2]; /* active hooks count */
unsigned int wake_mask; /* wakeup mask */
unsigned int changed_mask; /* changed wakeup mask */
} queue_shm_t;
typedef volatile union

View file

@ -126,9 +126,7 @@ struct msg_queue
struct object obj; /* object header */
struct fd *fd; /* optional file descriptor to poll */
unsigned int wake_bits; /* wakeup bits */
unsigned int wake_mask; /* wakeup mask */
unsigned int changed_bits; /* changed wakeup bits */
unsigned int changed_mask; /* changed wakeup mask */
int paint_count; /* pending paint messages count */
int hotkey_count; /* pending hotkey messages count */
int quit_message; /* is there a pending quit message? */
@ -303,9 +301,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
{
queue->fd = NULL;
queue->wake_bits = 0;
queue->wake_mask = 0;
queue->changed_bits = 0;
queue->changed_mask = 0;
queue->paint_count = 0;
queue->hotkey_count = 0;
queue->quit_message = 0;
@ -332,6 +328,8 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
SHARED_WRITE_BEGIN( queue->shared, queue_shm_t )
{
memset( (void *)shared->hooks_count, 0, sizeof(shared->hooks_count) );
shared->wake_mask = 0;
shared->changed_mask = 0;
}
SHARED_WRITE_END;
@ -642,7 +640,9 @@ void add_queue_hook_count( struct thread *thread, unsigned int index, int count
/* check the queue status */
static inline int is_signaled( struct msg_queue *queue )
{
return ((queue->wake_bits & queue->wake_mask) || (queue->changed_bits & queue->changed_mask));
const queue_shm_t *queue_shm = queue->shared;
return (queue->wake_bits & queue_shm->wake_mask) ||
(queue->changed_bits & queue_shm->changed_mask);
}
/* set some queue bits */
@ -1179,8 +1179,9 @@ static void msg_queue_remove_queue(struct object *obj, struct wait_queue_entry *
static void msg_queue_dump( struct object *obj, int verbose )
{
struct msg_queue *queue = (struct msg_queue *)obj;
const queue_shm_t *queue_shm = queue->shared;
fprintf( stderr, "Msg queue bits=%x mask=%x\n",
queue->wake_bits, queue->wake_mask );
queue->wake_bits, queue_shm->wake_mask );
}
static int msg_queue_signaled( struct object *obj, struct wait_queue_entry *entry )
@ -1203,8 +1204,14 @@ static int msg_queue_signaled( struct object *obj, struct wait_queue_entry *entr
static void msg_queue_satisfied( struct object *obj, struct wait_queue_entry *entry )
{
struct msg_queue *queue = (struct msg_queue *)obj;
queue->wake_mask = 0;
queue->changed_mask = 0;
const queue_shm_t *queue_shm = queue->shared;
SHARED_WRITE_BEGIN( queue_shm, queue_shm_t )
{
shared->wake_mask = 0;
shared->changed_mask = 0;
}
SHARED_WRITE_END;
}
static void msg_queue_destroy( struct object *obj )
@ -1313,7 +1320,9 @@ static int check_queue_input_window( struct msg_queue *queue, user_handle_t wind
void check_thread_queue_idle( struct thread *thread )
{
struct msg_queue *queue = thread->queue;
if ((queue->wake_mask & QS_SMRESULT)) return;
const queue_shm_t *queue_shm = queue->shared;
if ((queue_shm->wake_mask & QS_SMRESULT)) return;
if (thread->process->idle_event) set_event( thread->process->idle_event );
}
@ -2937,14 +2946,29 @@ DECL_HANDLER(set_queue_mask)
if (queue)
{
queue->wake_mask = req->wake_mask;
queue->changed_mask = req->changed_mask;
const queue_shm_t *queue_shm = queue->shared;
SHARED_WRITE_BEGIN( queue_shm, queue_shm_t )
{
shared->wake_mask = req->wake_mask;
shared->changed_mask = req->changed_mask;
}
SHARED_WRITE_END;
reply->wake_bits = queue->wake_bits;
reply->changed_bits = queue->changed_bits;
if (is_signaled( queue ))
{
/* if skip wait is set, do what would have been done in the subsequent wait */
if (req->skip_wait) queue->wake_mask = queue->changed_mask = 0;
if (req->skip_wait)
{
SHARED_WRITE_BEGIN( queue_shm, queue_shm_t )
{
shared->wake_mask = 0;
shared->changed_mask = 0;
}
SHARED_WRITE_END;
}
else wake_up( &queue->obj, 0 );
}
}
@ -3108,6 +3132,7 @@ DECL_HANDLER(get_message)
struct list *ptr;
struct msg_queue *queue = get_current_queue();
user_handle_t get_win = get_user_full_handle( req->get_win );
const queue_shm_t *queue_shm;
unsigned int filter = req->flags >> 16;
if (get_win && get_win != 1 && get_win != -1 && !get_user_object( get_win, USER_WINDOW ))
@ -3117,6 +3142,7 @@ DECL_HANDLER(get_message)
}
if (!queue) return;
queue_shm = queue->shared;
/* check for any hardware internal message */
if (get_hardware_message( current, req->hw_id, get_win, WM_WINE_FIRST_DRIVER_MSG,
@ -3200,8 +3226,14 @@ DECL_HANDLER(get_message)
}
if (get_win == -1 && current->process->idle_event) set_event( current->process->idle_event );
queue->wake_mask = req->wake_mask;
queue->changed_mask = req->changed_mask;
SHARED_WRITE_BEGIN( queue_shm, queue_shm_t )
{
shared->wake_mask = req->wake_mask;
shared->changed_mask = req->changed_mask;
}
SHARED_WRITE_END;
set_error( STATUS_PENDING ); /* FIXME */
}