Rebase against 7eb72b7bb3d3ea771efddcb5273e8a69456548ff.

This commit is contained in:
Alistair Leslie-Hughes
2024-06-08 08:26:32 +10:00
parent 88e86a23c0
commit 87a5dcecb7
6 changed files with 130 additions and 88 deletions

View File

@@ -1,4 +1,4 @@
From ec18233558b62aa736b5ecf20d2f7487e2823286 Mon Sep 17 00:00:00 2001
From 9b9b36ccc66866ba142ce1f0d12190025ac2e7f7 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Thu, 7 Jun 2018 20:09:59 -0500
Subject: [PATCH] server: Create server objects for eventfd-based
@@ -15,10 +15,10 @@ Subject: [PATCH] server: Create server objects for eventfd-based
create mode 100644 server/esync.h
diff --git a/server/Makefile.in b/server/Makefile.in
index 3b9446fe224..776faec63e4 100644
index ae502dbf17d..b164193ef20 100644
--- a/server/Makefile.in
+++ b/server/Makefile.in
@@ -11,6 +11,7 @@ C_SRCS = \
@@ -11,6 +11,7 @@ SOURCES = \
debugger.c \
device.c \
directory.c \
@@ -381,7 +381,7 @@ index 00000000000..00f9e638d83
+extern int do_esync(void);
+void esync_init(void);
diff --git a/server/main.c b/server/main.c
index a134d811d82..3436b0871b4 100644
index ddda5f4e86e..5062d0999fa 100644
--- a/server/main.c
+++ b/server/main.c
@@ -34,6 +34,7 @@
@@ -403,10 +403,10 @@ index a134d811d82..3436b0871b4 100644
set_current_time();
init_scheduler();
diff --git a/server/protocol.def b/server/protocol.def
index 99df502e398..9e15ada5bd0 100644
index e86d3414247..03bc0aeb11e 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3777,7 +3777,6 @@ struct handle_info
@@ -3867,7 +3867,6 @@ struct handle_info
obj_handle_t handle; /* process handle */
@END
@@ -414,11 +414,10 @@ index 99df502e398..9e15ada5bd0 100644
/* Iterate thread list for process */
@REQ(get_next_thread)
obj_handle_t process; /* process handle */
@@ -3788,3 +3787,27 @@ struct handle_info
@REPLY
@@ -3879,6 +3878,29 @@ struct handle_info
obj_handle_t handle; /* next thread handle */
@END
+
+enum esync_type
+{
+ ESYNC_SEMAPHORE = 1,
@@ -442,6 +441,14 @@ index 99df502e398..9e15ada5bd0 100644
+ int type; /* actual type (may be different for events) */
+ unsigned int shm_idx;
+@END
/* Setup keyboard auto-repeat */
@REQ(set_keyboard_repeat)
@@ -3888,3 +3910,4 @@ struct handle_info
@REPLY
int enable; /* previous state of auto-repeat enable */
@END
+
--
2.38.1
2.43.0

View File

@@ -1,4 +1,4 @@
From 193c44f510beed365640159cbdaeb0cb8186a7b0 Mon Sep 17 00:00:00 2001
From 2f23f37d5a1ba0d59d367729d96285ac7c470e8d Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Fri, 8 Jun 2018 18:55:49 -0500
Subject: [PATCH] server: Add a request to get the eventfd file descriptor
@@ -6,14 +6,14 @@ Subject: [PATCH] server: Add a request to get the eventfd file descriptor
---
server/esync.c | 37 +++++++++++++++++++++++++++++++++++++
server/protocol.def | 8 ++++++++
2 files changed, 45 insertions(+)
server/protocol.def | 9 ++++++++-
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/server/esync.c b/server/esync.c
index d646cb52bc2..cfbbcf55c48 100644
index f95dc5a391f..85f7f1e060f 100644
--- a/server/esync.c
+++ b/server/esync.c
@@ -335,3 +335,40 @@ DECL_HANDLER(create_esync)
@@ -333,3 +333,40 @@ DECL_HANDLER(create_esync)
if (root) release_object( root );
}
@@ -55,14 +55,13 @@ index d646cb52bc2..cfbbcf55c48 100644
+ release_object( obj );
+}
diff --git a/server/protocol.def b/server/protocol.def
index 552d504cc8d..9062a5020c2 100644
index 03bc0aeb11e..4ab6b97ba93 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3689,3 +3689,11 @@ enum esync_type
int type; /* actual type (may be different for events) */
@@ -3902,6 +3902,14 @@ enum esync_type
unsigned int shm_idx;
@END
+
+/* Retrieve the esync fd for an object. */
+@REQ(get_esync_fd)
+ obj_handle_t handle; /* handle to the object */
@@ -70,6 +69,15 @@ index 552d504cc8d..9062a5020c2 100644
+ int type;
+ unsigned int shm_idx;
+@END
+
/* Setup keyboard auto-repeat */
@REQ(set_keyboard_repeat)
int enable; /* whether to enable auto-repeat */
@@ -3910,4 +3918,3 @@ enum esync_type
@REPLY
int enable; /* previous state of auto-repeat enable */
@END
-
--
2.28.0
2.43.0

View File

@@ -1,4 +1,4 @@
From d7b142aa0b60d99bd225849439cd49119a6e3e80 Mon Sep 17 00:00:00 2001
From 465a4772356f406552cc20bddec820a4e197b667 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <zfigura@codeweavers.com>
Date: Mon, 6 Jul 2020 16:11:23 -0500
Subject: [PATCH] server, ntdll: Implement message waits.
@@ -6,8 +6,8 @@ Subject: [PATCH] server, ntdll: Implement message waits.
---
dlls/ntdll/unix/esync.c | 51 +++++++++++++++++++++++++++++++++++++++--
server/protocol.def | 5 ++++
server/queue.c | 21 +++++++++++++++++
3 files changed, 75 insertions(+), 2 deletions(-)
server/queue.c | 22 ++++++++++++++++++
3 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/esync.c b/dlls/ntdll/unix/esync.c
index 399930c444b..06d7d8babc6 100644
@@ -105,23 +105,25 @@ index 399930c444b..06d7d8babc6 100644
{
struct stat st;
diff --git a/server/protocol.def b/server/protocol.def
index a2700b043ba..fb290c7964c 100644
index 4ab6b97ba93..d28c1a6f5fa 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3907,3 +3907,8 @@ enum esync_type
int type;
@@ -3910,6 +3910,10 @@ enum esync_type
unsigned int shm_idx;
@END
+
+/* Notify the server that we are doing a message wait or done with one. */
+@REQ(esync_msgwait)
+ int in_msgwait; /* are we in a message wait? */
+@END
+
/* Setup keyboard auto-repeat */
@REQ(set_keyboard_repeat)
int enable; /* whether to enable auto-repeat */
diff --git a/server/queue.c b/server/queue.c
index 936a6309683..fc13b1cf6eb 100644
index 1568355104c..b68774d7524 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -148,6 +148,7 @@ struct msg_queue
@@ -149,6 +149,7 @@ struct msg_queue
int keystate_lock; /* owns an input keystate lock */
unsigned int ignore_post_msg; /* ignore post messages newer than this unique id */
int esync_fd; /* esync file descriptor (signalled on message) */
@@ -129,7 +131,7 @@ index 936a6309683..fc13b1cf6eb 100644
};
struct hotkey
@@ -321,6 +322,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
@@ -322,6 +323,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
queue->keystate_lock = 0;
queue->ignore_post_msg = 0;
queue->esync_fd = -1;
@@ -137,7 +139,7 @@ index 936a6309683..fc13b1cf6eb 100644
list_init( &queue->send_result );
list_init( &queue->callback_result );
list_init( &queue->pending_timers );
@@ -1108,6 +1110,10 @@ static int is_queue_hung( struct msg_queue *queue )
@@ -1115,6 +1117,10 @@ static int is_queue_hung( struct msg_queue *queue )
if (get_wait_queue_thread(entry)->queue == queue)
return 0; /* thread is waiting on queue -> not hung */
}
@@ -148,11 +150,10 @@ index 936a6309683..fc13b1cf6eb 100644
return 1;
}
@@ -3735,3 +3741,18 @@ DECL_HANDLER(update_rawinput_devices)
release_object( desktop );
@@ -3923,6 +3929,21 @@ DECL_HANDLER(update_rawinput_devices)
}
}
+
+DECL_HANDLER(esync_msgwait)
+{
+ struct msg_queue *queue = get_current_queue();
@@ -167,6 +168,15 @@ index 936a6309683..fc13b1cf6eb 100644
+ if (queue->fd)
+ set_fd_events( queue->fd, req->in_msgwait ? POLLIN : 0 );
+}
+
DECL_HANDLER(set_keyboard_repeat)
{
struct desktop *desktop;
@@ -3941,3 +3962,4 @@ DECL_HANDLER(set_keyboard_repeat)
release_object( desktop );
}
+
--
2.43.0

View File

@@ -1,4 +1,4 @@
From 2d3957bbd6fb87e30bde05713c97ad42d57b3cf1 Mon Sep 17 00:00:00 2001
From 5f5cfac7099cf4e5be912f07a66665f8217f57f3 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <zfigura@codeweavers.com>
Date: Mon, 6 Jul 2020 17:17:31 -0500
Subject: [PATCH] ntdll, server: Implement alertable waits.
@@ -15,10 +15,10 @@ Subject: [PATCH] ntdll, server: Implement alertable waits.
8 files changed, 109 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/unix/esync.c b/dlls/ntdll/unix/esync.c
index d1a282c65e9..2a7c3865617 100644
index 2844f9f760c..aeeea1731ce 100644
--- a/dlls/ntdll/unix/esync.c
+++ b/dlls/ntdll/unix/esync.c
@@ -607,17 +607,42 @@ static void update_grabbed_object( struct esync *obj )
@@ -599,17 +599,42 @@ static void update_grabbed_object( struct esync *obj )
static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_any,
BOOLEAN alertable, const LARGE_INTEGER *timeout )
{
@@ -62,7 +62,7 @@ index d1a282c65e9..2a7c3865617 100644
NtQuerySystemTime( &now );
if (timeout)
{
@@ -656,6 +681,8 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
@@ -648,6 +673,8 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
if (msgwait)
TRACE(" or driver events");
@@ -71,7 +71,7 @@ index d1a282c65e9..2a7c3865617 100644
if (!timeout)
TRACE(", timeout = INFINITE.\n");
@@ -692,12 +719,27 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
@@ -684,12 +711,27 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
fds[i].fd = obj ? obj->fd : -1;
fds[i].events = POLLIN;
}
@@ -100,7 +100,7 @@ index d1a282c65e9..2a7c3865617 100644
/* Find out which object triggered the wait. */
for (i = 0; i < count; i++)
{
@@ -771,6 +813,14 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
@@ -763,6 +805,14 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
tryagain:
/* First step: try to poll on each object in sequence. */
fds[0].events = POLLIN;
@@ -115,7 +115,7 @@ index d1a282c65e9..2a7c3865617 100644
for (i = 0; i < count; i++)
{
struct esync *obj = objs[i];
@@ -786,9 +836,11 @@ tryagain:
@@ -778,9 +828,11 @@ tryagain:
continue;
}
@@ -128,7 +128,7 @@ index d1a282c65e9..2a7c3865617 100644
if (fds[0].revents & (POLLHUP | POLLERR | POLLNVAL))
{
@@ -804,10 +856,12 @@ tryagain:
@@ -796,10 +848,12 @@ tryagain:
fds[i].fd = objs[i] ? objs[i]->fd : -1;
fds[i].events = POLLIN;
}
@@ -143,7 +143,7 @@ index d1a282c65e9..2a7c3865617 100644
{
/* Quick, grab everything. */
for (i = 0; i < count; i++)
@@ -873,6 +927,19 @@ err:
@@ -865,6 +919,19 @@ err:
ERR("ppoll failed: %s\n", strerror(errno));
return errno_to_status( errno );
}
@@ -164,10 +164,10 @@ index d1a282c65e9..2a7c3865617 100644
/* We need to let the server know when we are doing a message wait, and when we
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index c8c959029d0..1d40afcb569 100644
index b278ab8df84..a3f0368b731 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -52,6 +52,7 @@ struct ntdll_thread_data
@@ -93,6 +93,7 @@ struct ntdll_thread_data
{
void *cpu_data[16]; /* reserved for CPU-specific data */
void *kernel_stack; /* stack for thread startup and kernel syscalls */
@@ -176,10 +176,10 @@ index c8c959029d0..1d40afcb569 100644
int reply_fd; /* fd for receiving server replies */
int wait_fd[2]; /* fd for sleeping server requests */
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 83b8b892b0f..977bfdd2dd2 100644
index 2116b677adb..a7d0bb7e8c8 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -2888,6 +2888,7 @@ static TEB *init_teb( void *ptr, BOOL is_wow )
@@ -3646,6 +3646,7 @@ static TEB *init_teb( void *ptr, BOOL is_wow )
teb->StaticUnicodeString.Buffer = teb->StaticUnicodeBuffer;
teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
@@ -188,10 +188,10 @@ index 83b8b892b0f..977bfdd2dd2 100644
thread_data->reply_fd = -1;
thread_data->wait_fd[0] = -1;
diff --git a/server/esync.c b/server/esync.c
index ad5403bd4e0..3aa3a22df68 100644
index c5587bef6cf..0c365006f0b 100644
--- a/server/esync.c
+++ b/server/esync.c
@@ -348,19 +348,25 @@ int esync_create_fd( int initval, int flags )
@@ -346,19 +346,25 @@ int esync_create_fd( int initval, int flags )
#endif
}
@@ -221,7 +221,7 @@ index ad5403bd4e0..3aa3a22df68 100644
}
}
@@ -498,3 +504,9 @@ DECL_HANDLER(get_esync_fd)
@@ -496,3 +502,9 @@ DECL_HANDLER(get_esync_fd)
release_object( obj );
}
@@ -232,10 +232,10 @@ index ad5403bd4e0..3aa3a22df68 100644
+ send_client_fd( current->process, current->esync_apc_fd, current->id );
+}
diff --git a/server/esync.h b/server/esync.h
index aeb58c5469c..cea025d9308 100644
index 689d8569b73..e1588d205d9 100644
--- a/server/esync.h
+++ b/server/esync.h
@@ -21,6 +21,7 @@
@@ -23,6 +23,7 @@
extern int do_esync(void);
void esync_init(void);
int esync_create_fd( int initval, int flags );
@@ -244,22 +244,22 @@ index aeb58c5469c..cea025d9308 100644
void esync_clear( int fd );
diff --git a/server/protocol.def b/server/protocol.def
index 5eadd8795f2..bb6f1d1c589 100644
index 8c728080d05..3ea700054c6 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3784,3 +3784,7 @@ enum esync_type
@REQ(esync_msgwait)
int in_msgwait; /* are we in a message wait? */
@@ -3935,3 +3935,7 @@ enum esync_type
@REPLY
int enable; /* previous state of auto-repeat enable */
@END
+
+/* Retrieve the fd to wait on for user APCs. */
+@REQ(get_esync_apc_fd)
+@END
diff --git a/server/thread.c b/server/thread.c
index 10da1e3d4c7..258c3f28815 100644
index fd6b91b228a..8d7c520ced7 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -228,6 +228,7 @@ static inline void init_thread_structure( struct thread *thread )
@@ -232,6 +232,7 @@ static inline void init_thread_structure( struct thread *thread )
thread->teb = 0;
thread->entry_point = 0;
thread->esync_fd = -1;
@@ -267,7 +267,7 @@ index 10da1e3d4c7..258c3f28815 100644
thread->system_regs = 0;
thread->queue = NULL;
thread->wait = NULL;
@@ -375,7 +376,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
@@ -380,7 +381,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
}
if (do_esync())
@@ -278,7 +278,7 @@ index 10da1e3d4c7..258c3f28815 100644
set_fd_events( thread->request_fd, POLLIN ); /* start listening to events */
add_process_thread( thread->process, thread );
@@ -1164,8 +1168,13 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr
@@ -1174,8 +1178,13 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr
grab_object( apc );
list_add_tail( queue, &apc->entry );
if (!list_prev( queue, &apc->entry )) /* first one */
@@ -292,7 +292,7 @@ index 10da1e3d4c7..258c3f28815 100644
return 1;
}
@@ -1211,6 +1220,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system
@@ -1221,6 +1230,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system
apc = LIST_ENTRY( ptr, struct thread_apc, entry );
list_remove( ptr );
}
@@ -304,10 +304,10 @@ index 10da1e3d4c7..258c3f28815 100644
}
diff --git a/server/thread.h b/server/thread.h
index 8a5a8501d9c..e5145f9eb07 100644
index 9129e473ba9..10e9e28b432 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -55,6 +55,7 @@ struct thread
@@ -56,6 +56,7 @@ struct thread
thread_id_t id; /* thread id */
struct list mutex_list; /* list of currently owned mutexes */
int esync_fd; /* esync file descriptor (signalled on exit) */
@@ -316,5 +316,5 @@ index 8a5a8501d9c..e5145f9eb07 100644
struct msg_queue *queue; /* message queue */
struct thread_wait *wait; /* current wait condition if sleeping */
--
2.30.2
2.43.0