Rebase against 18883a76762afab3e18e1279a9666240e19d4d03.

This commit is contained in:
Zebediah Figura
2019-04-08 17:01:18 -05:00
parent be0910e9a9
commit 52a77f6b00
16 changed files with 163 additions and 385 deletions

View File

@@ -1,11 +1,10 @@
From f3596cd66ac694d4a7633f91bc53a2f44b2608cc Mon Sep 17 00:00:00 2001
From bb968ec541ccdcd1b04b4b967065d5ee81f3fd78 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Thu, 7 Jun 2018 21:23:52 -0500
Subject: [PATCH 07/83] ntdll: Implement waiting on esync objects.
Subject: [PATCH] ntdll: Implement waiting on esync objects.
This is the most basic case: WAIT_ANY. We use poll() (actually ppoll(), for
the better granularity) to select on all of the handles that we can.
---
dlls/ntdll/esync.c | 161 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ntdll/esync.h | 3 +
@@ -13,7 +12,7 @@ the better granularity) to select on all of the handles that we can.
3 files changed, 171 insertions(+)
diff --git a/dlls/ntdll/esync.c b/dlls/ntdll/esync.c
index f7a427425..0950d8b5a 100644
index f7a427425..f6ceefe53 100644
--- a/dlls/ntdll/esync.c
+++ b/dlls/ntdll/esync.c
@@ -22,6 +22,13 @@
@@ -118,14 +117,14 @@ index f7a427425..0950d8b5a 100644
+ {
+ TRACE("Waiting for %s of %d handles:", wait_any ? "any" : "all", count);
+ for (i = 0; i < count; i++)
+ DPRINTF(" %p", handles[i]);
+ TRACE(" %p", handles[i]);
+
+ if (!timeout)
+ DPRINTF(", timeout = INFINITE.\n");
+ TRACE(", timeout = INFINITE.\n");
+ else
+ {
+ timeleft = update_timeout( end );
+ DPRINTF(", timeout = %ld.%07ld sec.\n",
+ TRACE(", timeout = %ld.%07ld sec.\n",
+ (long) timeleft / TICKSPERSEC, (long) timeleft % TICKSPERSEC);
+ }
+ }
@@ -221,5 +220,5 @@ index 93052ddb5..40bc619a2 100644
select_op.wait.op = wait_any ? SELECT_WAIT : SELECT_WAIT_ALL;
for (i = 0; i < count; i++) select_op.wait.handles[i] = wine_server_obj_handle( handles[i] );
--
2.20.1
2.21.0

View File

@@ -1,8 +1,7 @@
From 69c158267facd8919329e71e082e872031ee4054 Mon Sep 17 00:00:00 2001
From f3bcb0b64f7960dad656347dadb56be9b3afe262 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Fri, 8 Jun 2018 22:04:29 -0500
Subject: [PATCH 20/83] server: Create eventfd file descriptors for thread
objects.
Subject: [PATCH] server: Create eventfd file descriptors for thread objects.
---
server/thread.c | 16 +++++++++++++++-
@@ -10,7 +9,7 @@ Subject: [PATCH 20/83] server: Create eventfd file descriptors for thread
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/server/thread.c b/server/thread.c
index ae00c89da..e82d71f67 100644
index 85349475c..35bddeeaa 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -133,6 +133,7 @@ static const struct object_ops thread_apc_ops =
@@ -20,8 +19,8 @@ index ae00c89da..e82d71f67 100644
+static int thread_get_esync_fd( struct object *obj );
static unsigned int thread_map_access( struct object *obj, unsigned int access );
static void thread_poll_event( struct fd *fd, int event );
static void destroy_thread( struct object *obj );
@@ -145,7 +146,7 @@ static const struct object_ops thread_ops =
static struct list *thread_get_kernel_obj_list( struct object *obj );
@@ -146,7 +147,7 @@ static const struct object_ops thread_ops =
add_queue, /* add_queue */
remove_queue, /* remove_queue */
thread_signaled, /* signaled */
@@ -30,7 +29,7 @@ index ae00c89da..e82d71f67 100644
no_satisfied, /* satisfied */
no_signal, /* signal */
no_get_fd, /* get_fd */
@@ -185,6 +186,7 @@ static inline void init_thread_structure( struct thread *thread )
@@ -186,6 +187,7 @@ static inline void init_thread_structure( struct thread *thread )
thread->suspend_context = NULL;
thread->teb = 0;
thread->entry_point = 0;
@@ -38,7 +37,7 @@ index ae00c89da..e82d71f67 100644
thread->debug_ctx = NULL;
thread->debug_event = NULL;
thread->debug_break = 0;
@@ -292,6 +294,9 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
@@ -294,6 +296,9 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
return NULL;
}
@@ -48,7 +47,7 @@ index ae00c89da..e82d71f67 100644
set_fd_events( thread->request_fd, POLLIN ); /* start listening to events */
add_process_thread( thread->process, thread );
return thread;
@@ -364,6 +369,9 @@ static void destroy_thread( struct object *obj )
@@ -372,6 +377,9 @@ static void destroy_thread( struct object *obj )
if (thread->exit_poll) remove_timeout_user( thread->exit_poll );
if (thread->id) free_ptid( thread->id );
if (thread->token) release_object( thread->token );
@@ -58,7 +57,7 @@ index ae00c89da..e82d71f67 100644
}
/* dump a thread on stdout for debugging purposes */
@@ -388,6 +396,12 @@ static int thread_signaled( struct object *obj, struct wait_queue_entry *entry )
@@ -397,6 +405,12 @@ static int thread_signaled( struct object *obj, struct wait_queue_entry *entry )
return mythread->state == TERMINATED && !mythread->exit_poll;
}
@@ -72,7 +71,7 @@ index ae00c89da..e82d71f67 100644
{
if (access & GENERIC_READ) access |= STANDARD_RIGHTS_READ | THREAD_QUERY_INFORMATION | THREAD_GET_CONTEXT;
diff --git a/server/thread.h b/server/thread.h
index bfd818ce2..4913577f7 100644
index fa4ced546..46064cb4a 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -54,6 +54,7 @@ struct thread
@@ -84,5 +83,5 @@ index bfd818ce2..4913577f7 100644
struct debug_event *debug_event; /* debug event being sent to debugger */
int debug_break; /* debug breakpoint pending? */
--
2.20.1
2.21.0

View File

@@ -1,8 +1,8 @@
From e3a723494fcecb85cebeeb8557aa21cf3f30f0b1 Mon Sep 17 00:00:00 2001
From 29517778d9000de8de3217bcd6f1a2bb933123c6 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sat, 9 Jun 2018 14:44:54 -0500
Subject: [PATCH 24/83] server, ntdll: Also wait on the queue fd when waiting
for driver events.
Subject: [PATCH] server, ntdll: Also wait on the queue fd when waiting for
driver events.
Normally the server handles this, by polling on the fd during its main loop.
The problem there is that the server only polls when the thread is waiting
@@ -23,7 +23,7 @@ fix the 'drives' tab.
8 files changed, 60 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/esync.c b/dlls/ntdll/esync.c
index 210556fc2..4d708c6df 100644
index 5d8dbac2d..dcb7801d9 100644
--- a/dlls/ntdll/esync.c
+++ b/dlls/ntdll/esync.c
@@ -80,17 +80,9 @@ void __wine_esync_set_queue_fd( int fd )
@@ -100,13 +100,13 @@ index 210556fc2..4d708c6df 100644
FIXME("Can't wait on esync and server objects at the same time!\n");
@@ -510,6 +515,9 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
for (i = 0; i < count; i++)
DPRINTF(" %p", handles[i]);
TRACE(" %p", handles[i]);
+ if (msgwait)
+ DPRINTF(" or driver events (fd %d)", ntdll_get_thread_data()->esync_queue_fd);
+ TRACE(" or driver events (fd %d)", ntdll_get_thread_data()->esync_queue_fd);
+
if (!timeout)
DPRINTF(", timeout = INFINITE.\n");
TRACE(", timeout = INFINITE.\n");
else
@@ -527,10 +535,16 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
fds[i].fd = objs[i] ? objs[i]->fd : -1;
@@ -176,7 +176,7 @@ index 4f7ff6bda..1f8c0d516 100644
}
else
diff --git a/server/event.c b/server/event.c
index 62d8bf7d3..9e0bf8cbf 100644
index d2f9e378c..79287e7ed 100644
--- a/server/event.c
+++ b/server/event.c
@@ -50,7 +50,7 @@ static void event_dump( struct object *obj, int verbose );
@@ -188,7 +188,7 @@ index 62d8bf7d3..9e0bf8cbf 100644
static unsigned int event_map_access( struct object *obj, unsigned int access );
static int event_signal( struct object *obj, unsigned int access);
static struct list *event_get_kernel_obj_list( struct object *obj );
@@ -202,9 +202,10 @@ static int event_signaled( struct object *obj, struct wait_queue_entry *entry )
@@ -203,9 +203,10 @@ static int event_signaled( struct object *obj, struct wait_queue_entry *entry )
return event->signaled;
}
@@ -201,7 +201,7 @@ index 62d8bf7d3..9e0bf8cbf 100644
}
diff --git a/server/object.h b/server/object.h
index 592b76617..23dcdafa4 100644
index ee0f1f776..ca5a191f9 100644
--- a/server/object.h
+++ b/server/object.h
@@ -69,7 +69,7 @@ struct object_ops
@@ -214,7 +214,7 @@ index 592b76617..23dcdafa4 100644
void (*satisfied)(struct object *,struct wait_queue_entry *);
/* signal an object */
diff --git a/server/process.c b/server/process.c
index 0bb220dba..d2fa0f3a8 100644
index 1ce2fb05c..6e6dfc41c 100644
--- a/server/process.c
+++ b/server/process.c
@@ -67,7 +67,7 @@ static unsigned int process_map_access( struct object *obj, unsigned int access
@@ -226,7 +226,7 @@ index 0bb220dba..d2fa0f3a8 100644
static void terminate_process( struct process *process, struct thread *skip, int exit_code );
static const struct object_ops process_ops =
@@ -652,9 +652,10 @@ static int process_signaled( struct object *obj, struct wait_queue_entry *entry
@@ -654,9 +654,10 @@ static int process_signaled( struct object *obj, struct wait_queue_entry *entry
return !process->running_threads;
}
@@ -239,10 +239,10 @@ index 0bb220dba..d2fa0f3a8 100644
}
diff --git a/server/protocol.def b/server/protocol.def
index 5f2d77bc7..cebe0e88e 100644
index 17959c233..8d2df1f97 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -4056,4 +4056,14 @@ struct handle_info
@@ -4012,4 +4012,14 @@ struct handle_info
@REQ(get_esync_fd)
obj_handle_t handle; /* handle to the object */
@REPLY
@@ -283,7 +283,7 @@ index 0ea95291c..91de4a3a8 100644
}
diff --git a/server/thread.c b/server/thread.c
index e82d71f67..539cd0491 100644
index 35bddeeaa..7c8ff1d5d 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -133,7 +133,7 @@ static const struct object_ops thread_apc_ops =
@@ -294,8 +294,8 @@ index e82d71f67..539cd0491 100644
+static int thread_get_esync_fd( struct object *obj, enum esync_type *type );
static unsigned int thread_map_access( struct object *obj, unsigned int access );
static void thread_poll_event( struct fd *fd, int event );
static void destroy_thread( struct object *obj );
@@ -396,9 +396,10 @@ static int thread_signaled( struct object *obj, struct wait_queue_entry *entry )
static struct list *thread_get_kernel_obj_list( struct object *obj );
@@ -405,9 +405,10 @@ static int thread_signaled( struct object *obj, struct wait_queue_entry *entry )
return mythread->state == TERMINATED && !mythread->exit_poll;
}
@@ -308,5 +308,5 @@ index e82d71f67..539cd0491 100644
}
--
2.20.1
2.21.0

View File

@@ -1,11 +1,11 @@
From 62de87cd8e8ed0006315080e06c96947727f89b2 Mon Sep 17 00:00:00 2001
From 216028748c99e8ea03c913b7885e2e97c6c0fbca Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Fri, 15 Jun 2018 14:12:22 -0500
Subject: [PATCH 45/83] server, ntdll: Implement alertable waits.
Subject: [PATCH] server, ntdll: Implement alertable waits.
We do this quite simply by waiting on an extra eventfd descriptor, which the server signals when a user APC is queued.
---
dlls/ntdll/esync.c | 94 +++++++++++++++++++++++++++++++++++------
dlls/ntdll/esync.c | 95 +++++++++++++++++++++++++++++++++++------
dlls/ntdll/ntdll_misc.h | 1 +
dlls/ntdll/thread.c | 2 +
server/esync.c | 20 +++++++--
@@ -13,10 +13,10 @@ We do this quite simply by waiting on an extra eventfd descriptor, which the ser
server/protocol.def | 5 +++
server/thread.c | 13 ++++++
server/thread.h | 1 +
8 files changed, 120 insertions(+), 17 deletions(-)
8 files changed, 121 insertions(+), 17 deletions(-)
diff --git a/dlls/ntdll/esync.c b/dlls/ntdll/esync.c
index 227dd3df0..583174499 100644
index 119a36f36..8a41f6961 100644
--- a/dlls/ntdll/esync.c
+++ b/dlls/ntdll/esync.c
@@ -684,19 +684,43 @@ static int do_poll( struct pollfd *fds, nfds_t nfds, ULONGLONG *end )
@@ -65,16 +65,17 @@ index 227dd3df0..583174499 100644
NtQuerySystemTime( &now );
if (timeout)
{
@@ -747,6 +771,8 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
@@ -748,6 +772,9 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
if (msgwait)
DPRINTF(" or driver events (fd %d)", ntdll_get_thread_data()->esync_queue_fd);
+ if (alertable)
+ DPRINTF(", alertable");
TRACE(" or driver events (fd %d)", ntdll_get_thread_data()->esync_queue_fd);
+ if (alertable)
+ TRACE(", alertable");
+
if (!timeout)
DPRINTF(", timeout = INFINITE.\n");
@@ -785,10 +811,17 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
TRACE(", timeout = INFINITE.\n");
else
@@ -785,10 +812,17 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
}
if (msgwait)
{
@@ -84,18 +85,18 @@ index 227dd3df0..583174499 100644
+ fds[i].fd = ntdll_get_thread_data()->esync_queue_fd;
+ fds[i].events = POLLIN;
+ i++;
+ }
}
+ if (alertable)
+ {
+ fds[i].fd = ntdll_get_thread_data()->esync_apc_fd;
+ fds[i].events = POLLIN;
+ i++;
}
+ }
+ pollcount = i;
while (1)
{
@@ -848,10 +881,18 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
@@ -848,10 +882,18 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
}
}
@@ -117,7 +118,7 @@ index 227dd3df0..583174499 100644
}
/* If we got here, someone else stole (or reset, etc.) whatever
@@ -890,6 +931,14 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
@@ -890,6 +932,14 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
tryagain:
/* First step: try to poll on each object in sequence. */
fds[0].events = POLLIN;
@@ -132,7 +133,7 @@ index 227dd3df0..583174499 100644
for (i = 0; i < count; i++)
{
struct esync *obj = objs[i];
@@ -905,9 +954,11 @@ tryagain:
@@ -905,9 +955,11 @@ tryagain:
continue;
}
@@ -145,7 +146,7 @@ index 227dd3df0..583174499 100644
if (fds[0].revents & (POLLHUP | POLLERR | POLLNVAL))
{
@@ -920,9 +971,11 @@ tryagain:
@@ -920,9 +972,11 @@ tryagain:
if (msgwait)
{
fds[0].fd = ntdll_get_thread_data()->esync_queue_fd;
@@ -158,7 +159,7 @@ index 227dd3df0..583174499 100644
}
/* If we got here and we haven't timed out, that means all of the
@@ -934,10 +987,12 @@ tryagain:
@@ -934,10 +988,12 @@ tryagain:
}
if (msgwait)
{
@@ -174,7 +175,7 @@ index 227dd3df0..583174499 100644
/* Poll everything to see if they're still signaled. */
ret = poll( fds, pollcount, 0 );
@@ -1018,6 +1073,19 @@ err:
@@ -1018,6 +1074,19 @@ err:
ERR("ppoll failed: %s\n", strerror(errno));
return FILE_GetNtStatus();
}
@@ -195,10 +196,10 @@ index 227dd3df0..583174499 100644
NTSTATUS esync_signal_and_wait( HANDLE signal, HANDLE wait, BOOLEAN alertable,
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index e2ef7d9b8..b6c410c7f 100644
index 951c9b7f9..5574e24fd 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -281,6 +281,7 @@ struct ntdll_thread_data
@@ -241,6 +241,7 @@ struct ntdll_thread_data
{
struct debug_info *debug_info; /* info for debugstr functions */
int esync_queue_fd;/* fd to wait on for driver events */
@@ -207,10 +208,10 @@ index e2ef7d9b8..b6c410c7f 100644
int request_fd; /* fd for sending server requests */
int reply_fd; /* fd for receiving server replies */
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 04aa8dff8..d146b9e00 100644
index 1d55162a6..dd553a864 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -328,6 +328,7 @@ void thread_init(void)
@@ -319,6 +319,7 @@ void thread_init(void)
thread_data->wait_fd[0] = -1;
thread_data->wait_fd[1] = -1;
thread_data->esync_queue_fd = -1;
@@ -218,7 +219,7 @@ index 04aa8dff8..d146b9e00 100644
signal_init_thread( teb );
virtual_init_threading();
@@ -700,6 +701,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle_ptr, ACCESS_MASK access, OBJECT
@@ -691,6 +692,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle_ptr, ACCESS_MASK access, OBJECT
thread_data->wait_fd[1] = -1;
thread_data->start_stack = (char *)teb->Tib.StackBase;
thread_data->esync_queue_fd = -1;
@@ -283,10 +284,10 @@ index aeb58c546..cea025d93 100644
void esync_clear( int fd );
diff --git a/server/protocol.def b/server/protocol.def
index 3037b8161..f55da3a0e 100644
index 4002ee642..ce165b71b 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -4076,6 +4076,11 @@ struct handle_info
@@ -4032,6 +4032,11 @@ struct handle_info
unsigned int shm_idx; /* this object's index into the shm section */
@END
@@ -299,10 +300,10 @@ index 3037b8161..f55da3a0e 100644
{
ESYNC_SEMAPHORE = 1,
diff --git a/server/thread.c b/server/thread.c
index 539cd0491..24756d079 100644
index 7c8ff1d5d..0e02630b9 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -187,6 +187,7 @@ static inline void init_thread_structure( struct thread *thread )
@@ -188,6 +188,7 @@ static inline void init_thread_structure( struct thread *thread )
thread->teb = 0;
thread->entry_point = 0;
thread->esync_fd = -1;
@@ -310,7 +311,7 @@ index 539cd0491..24756d079 100644
thread->debug_ctx = NULL;
thread->debug_event = NULL;
thread->debug_break = 0;
@@ -295,7 +296,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
@@ -297,7 +298,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
}
if (do_esync())
@@ -321,7 +322,7 @@ index 539cd0491..24756d079 100644
set_fd_events( thread->request_fd, POLLIN ); /* start listening to events */
add_process_thread( thread->process, thread );
@@ -1043,8 +1047,13 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr
@@ -1052,8 +1056,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 */
@@ -335,7 +336,7 @@ index 539cd0491..24756d079 100644
return 1;
}
@@ -1091,6 +1100,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system_
@@ -1100,6 +1109,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system_
apc = LIST_ENTRY( ptr, struct thread_apc, entry );
list_remove( ptr );
}
@@ -347,7 +348,7 @@ index 539cd0491..24756d079 100644
}
diff --git a/server/thread.h b/server/thread.h
index 4913577f7..1b3bef479 100644
index 46064cb4a..36ccb9207 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -55,6 +55,7 @@ struct thread
@@ -359,5 +360,5 @@ index 4913577f7..1b3bef479 100644
struct debug_event *debug_event; /* debug event being sent to debugger */
int debug_break; /* debug breakpoint pending? */
--
2.20.1
2.21.0