eventfd_synchronization: Backport some fixes that didn' make it into wine-staging.

This commit is contained in:
Zebediah Figura 2022-05-13 21:13:29 -05:00
parent ea360c871f
commit e534d6546a
6 changed files with 93 additions and 83 deletions

View File

@ -1,4 +1,4 @@
From 27524b275c81c1c9057e4b4ca3d9cec734a3bd8a Mon Sep 17 00:00:00 2001
From 846f2603e9d2a3a3b5a56b0e1140bb49a95053a6 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
@ -7,10 +7,10 @@ Subject: [PATCH] server: Create server objects for eventfd-based
---
server/Makefile.in | 1 +
server/esync.c | 318 ++++++++++++++++++++++++++++++++++++++++++++
server/esync.h | 22 +++
server/esync.h | 24 ++++
server/main.c | 4 +
server/protocol.def | 25 +++-
5 files changed, 369 insertions(+), 1 deletion(-)
5 files changed, 371 insertions(+), 1 deletion(-)
create mode 100644 server/esync.c
create mode 100644 server/esync.h
@ -352,10 +352,10 @@ index 00000000000..b9dbfa322bc
+}
diff --git a/server/esync.h b/server/esync.h
new file mode 100644
index 00000000000..7ca4ca89394
index 00000000000..00f9e638d83
--- /dev/null
+++ b/server/esync.h
@@ -0,0 +1,22 @@
@@ -0,0 +1,24 @@
+/*
+ * eventfd-based synchronization objects
+ *
@ -376,6 +376,8 @@ index 00000000000..7ca4ca89394
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <unistd.h>
+
+extern int do_esync(void);
+void esync_init(void);
diff --git a/server/main.c b/server/main.c
@ -401,10 +403,10 @@ index a134d811d82..3436b0871b4 100644
set_current_time();
init_scheduler();
diff --git a/server/protocol.def b/server/protocol.def
index c413cc7d7bb..607d56a666c 100644
index 6bfcda213a4..6b0e0e6f6e4 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3733,7 +3733,6 @@ struct handle_info
@@ -3738,7 +3738,6 @@ struct handle_info
obj_handle_t handle; /* process handle */
@END
@ -412,7 +414,7 @@ index c413cc7d7bb..607d56a666c 100644
/* Iterate thread list for process */
@REQ(get_next_thread)
obj_handle_t process; /* process handle */
@@ -3744,3 +3743,27 @@ struct handle_info
@@ -3749,3 +3748,27 @@ struct handle_info
@REPLY
obj_handle_t handle; /* next thread handle */
@END
@ -441,5 +443,5 @@ index c413cc7d7bb..607d56a666c 100644
+ unsigned int shm_idx;
+@END
--
2.33.0
2.35.1

View File

@ -1,4 +1,4 @@
From 670ee9563c1021c05993ef8525a4661daa01d3dd Mon Sep 17 00:00:00 2001
From dcb50e04b4ec205f4a6688c71a23cb2863cffce6 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Fri, 8 Jun 2018 21:01:24 -0500
Subject: [PATCH] server: Create eventfd file descriptors for event objects.
@ -9,14 +9,14 @@ This lets system processes shut down.
---
server/esync.c | 8 ++++++++
server/esync.h | 1 +
server/event.c | 30 ++++++++++++++++++++++++++++--
3 files changed, 37 insertions(+), 2 deletions(-)
server/event.c | 29 +++++++++++++++++++++++++++--
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/server/esync.c b/server/esync.c
index 2b9307267f9..975e5d2ddd6 100644
index 6696119b207..8cb46c4f2ce 100644
--- a/server/esync.c
+++ b/server/esync.c
@@ -331,6 +331,14 @@ void esync_wake_up( struct object *obj )
@@ -329,6 +329,14 @@ void esync_wake_up( struct object *obj )
}
}
@ -32,27 +32,19 @@ index 2b9307267f9..975e5d2ddd6 100644
{
struct esync *esync;
diff --git a/server/esync.h b/server/esync.h
index 1e12560ddd6..fcbfd0989bb 100644
index 1241e6d9f1a..d259b5f604d 100644
--- a/server/esync.h
+++ b/server/esync.h
@@ -22,3 +22,4 @@ extern int do_esync(void);
@@ -24,3 +24,4 @@ extern int do_esync(void);
void esync_init(void);
int esync_create_fd( int initval, int flags );
void esync_wake_up( struct object *obj );
+void esync_clear( int fd );
diff --git a/server/event.c b/server/event.c
index c727bfdd1ba..69126abc096 100644
index c727bfdd1ba..f1a88e3d23f 100644
--- a/server/event.c
+++ b/server/event.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <unistd.h>
#include <sys/types.h>
#include "ntstatus.h"
@@ -35,6 +36,7 @@
@@ -35,6 +35,7 @@
#include "thread.h"
#include "request.h"
#include "security.h"
@ -60,7 +52,7 @@ index c727bfdd1ba..69126abc096 100644
static const WCHAR event_name[] = {'E','v','e','n','t'};
@@ -56,13 +58,16 @@ struct event
@@ -56,13 +57,16 @@ struct event
struct list kernel_object; /* list of kernel object pointers */
int manual_reset; /* is it a manual reset event? */
int signaled; /* event has been signaled */
@ -77,7 +69,7 @@ index c727bfdd1ba..69126abc096 100644
static const struct object_ops event_ops =
{
@@ -72,7 +77,7 @@ static const struct object_ops event_ops =
@@ -72,7 +76,7 @@ static const struct object_ops event_ops =
add_queue, /* add_queue */
remove_queue, /* remove_queue */
event_signaled, /* signaled */
@ -86,7 +78,7 @@ index c727bfdd1ba..69126abc096 100644
event_satisfied, /* satisfied */
event_signal, /* signal */
no_get_fd, /* get_fd */
@@ -86,7 +91,7 @@ static const struct object_ops event_ops =
@@ -86,7 +90,7 @@ static const struct object_ops event_ops =
no_open_file, /* open_file */
event_get_kernel_obj_list, /* get_kernel_obj_list */
no_close_handle, /* close_handle */
@ -95,7 +87,7 @@ index c727bfdd1ba..69126abc096 100644
};
@@ -152,6 +157,9 @@ struct event *create_event( struct object *root, const struct unicode_str *name,
@@ -152,6 +156,9 @@ struct event *create_event( struct object *root, const struct unicode_str *name,
list_init( &event->kernel_object );
event->manual_reset = manual_reset;
event->signaled = initial_state;
@ -105,7 +97,7 @@ index c727bfdd1ba..69126abc096 100644
}
}
return event;
@@ -180,6 +188,9 @@ void set_event( struct event *event )
@@ -180,6 +187,9 @@ void set_event( struct event *event )
void reset_event( struct event *event )
{
event->signaled = 0;
@ -115,7 +107,7 @@ index c727bfdd1ba..69126abc096 100644
}
static void event_dump( struct object *obj, int verbose )
@@ -197,6 +208,13 @@ static int event_signaled( struct object *obj, struct wait_queue_entry *entry )
@@ -197,6 +207,13 @@ static int event_signaled( struct object *obj, struct wait_queue_entry *entry )
return event->signaled;
}
@ -129,7 +121,7 @@ index c727bfdd1ba..69126abc096 100644
static void event_satisfied( struct object *obj, struct wait_queue_entry *entry )
{
struct event *event = (struct event *)obj;
@@ -225,6 +243,14 @@ static struct list *event_get_kernel_obj_list( struct object *obj )
@@ -225,6 +242,14 @@ static struct list *event_get_kernel_obj_list( struct object *obj )
return &event->kernel_object;
}
@ -145,5 +137,5 @@ index c727bfdd1ba..69126abc096 100644
unsigned int attr, const struct security_descriptor *sd )
{
--
2.33.0
2.35.1

View File

@ -1,14 +1,14 @@
From a273680e7cbdc66e9fdb6fd6482803ddfed94dca Mon Sep 17 00:00:00 2001
From 0d55971a114d650b7826e01e43ccd3a60597fefd Mon Sep 17 00:00:00 2001
From: Zebediah Figura <zfigura@codeweavers.com>
Date: Mon, 6 Jul 2020 16:01:56 -0500
Subject: [PATCH] server: Create eventfd file descriptors for message queues.
---
server/queue.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
server/queue.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/server/queue.c b/server/queue.c
index b6decc521e9..e70c0f5ad81 100644
index b6decc521e9..23fb338924e 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -41,6 +41,7 @@
@ -85,7 +85,15 @@ index b6decc521e9..e70c0f5ad81 100644
static void msg_queue_satisfied( struct object *obj, struct wait_queue_entry *entry )
{
struct msg_queue *queue = (struct msg_queue *)obj;
@@ -2485,6 +2502,9 @@ DECL_HANDLER(set_queue_mask)
@@ -1090,6 +1107,7 @@ static void msg_queue_destroy( struct object *obj )
release_object( queue->input );
if (queue->hooks) release_object( queue->hooks );
if (queue->fd) release_object( queue->fd );
+ if (do_esync()) close( queue->esync_fd );
}
static void msg_queue_poll_event( struct fd *fd, int event )
@@ -2485,6 +2503,9 @@ DECL_HANDLER(set_queue_mask)
if (req->skip_wait) queue->wake_mask = queue->changed_mask = 0;
else wake_up( &queue->obj, 0 );
}
@ -95,7 +103,7 @@ index b6decc521e9..e70c0f5ad81 100644
}
}
@@ -2498,6 +2518,9 @@ DECL_HANDLER(get_queue_status)
@@ -2498,6 +2519,9 @@ DECL_HANDLER(get_queue_status)
reply->wake_bits = queue->wake_bits;
reply->changed_bits = queue->changed_bits;
queue->changed_bits &= ~req->clear_bits;
@ -105,7 +113,7 @@ index b6decc521e9..e70c0f5ad81 100644
}
else reply->wake_bits = reply->changed_bits = 0;
}
@@ -2746,6 +2769,10 @@ DECL_HANDLER(get_message)
@@ -2746,6 +2770,10 @@ DECL_HANDLER(get_message)
queue->wake_mask = req->wake_mask;
queue->changed_mask = req->changed_mask;
set_error( STATUS_PENDING ); /* FIXME */
@ -117,5 +125,5 @@ index b6decc521e9..e70c0f5ad81 100644
found_msg:
--
2.34.1
2.35.1

View File

@ -1,4 +1,4 @@
From 3518ce5bf3c6010425f35bb228b3fb2b238b1726 Mon Sep 17 00:00:00 2001
From 8111350c608821aa86c6acfb4959446abf97d382 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sat, 9 Jun 2018 15:39:37 -0500
Subject: [PATCH] server: Create eventfd descriptors for device manager
@ -11,22 +11,14 @@ process.
This lets drivers like mountmgr finally work, and so winecfg can open the
Drives tab.
---
server/device.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
server/device.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/server/device.c b/server/device.c
index 80904d33d0d..2a7727f05ae 100644
index f730fa81afa..c45d0102a56 100644
--- a/server/device.c
+++ b/server/device.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <unistd.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -38,6 +39,7 @@
@@ -38,6 +38,7 @@
#include "handle.h"
#include "request.h"
#include "process.h"
@ -34,7 +26,7 @@ index 80904d33d0d..2a7727f05ae 100644
/* IRP object */
@@ -93,10 +95,12 @@ struct device_manager
@@ -93,10 +94,12 @@ struct device_manager
struct list requests; /* list of pending irps across all devices */
struct irp_call *current_call; /* call currently executed on client side */
struct wine_rb_tree kernel_objects; /* map of objects that have client side pointer associated */
@ -47,7 +39,7 @@ index 80904d33d0d..2a7727f05ae 100644
static void device_manager_destroy( struct object *obj );
static const struct object_ops device_manager_ops =
@@ -107,7 +111,7 @@ static const struct object_ops device_manager_ops =
@@ -107,7 +110,7 @@ static const struct object_ops device_manager_ops =
add_queue, /* add_queue */
remove_queue, /* remove_queue */
device_manager_signaled, /* signaled */
@ -56,7 +48,7 @@ index 80904d33d0d..2a7727f05ae 100644
no_satisfied, /* satisfied */
no_signal, /* signal */
no_get_fd, /* get_fd */
@@ -751,6 +755,9 @@ static void delete_file( struct device_file *file )
@@ -751,6 +754,9 @@ static void delete_file( struct device_file *file )
/* terminate all pending requests */
LIST_FOR_EACH_ENTRY_SAFE( irp, next, &file->requests, struct irp_call, dev_entry )
{
@ -66,7 +58,7 @@ index 80904d33d0d..2a7727f05ae 100644
list_remove( &irp->mgr_entry );
set_irp_result( irp, STATUS_FILE_DELETED, NULL, 0, 0 );
}
@@ -786,6 +793,13 @@ static int device_manager_signaled( struct object *obj, struct wait_queue_entry
@@ -786,6 +792,13 @@ static int device_manager_signaled( struct object *obj, struct wait_queue_entry
return !list_empty( &manager->requests );
}
@ -80,7 +72,7 @@ index 80904d33d0d..2a7727f05ae 100644
static void device_manager_destroy( struct object *obj )
{
struct device_manager *manager = (struct device_manager *)obj;
@@ -820,6 +834,9 @@ static void device_manager_destroy( struct object *obj )
@@ -820,6 +833,9 @@ static void device_manager_destroy( struct object *obj )
assert( !irp->file && !irp->async );
release_object( irp );
}
@ -90,7 +82,7 @@ index 80904d33d0d..2a7727f05ae 100644
}
static struct device_manager *create_device_manager(void)
@@ -832,6 +849,9 @@ static struct device_manager *create_device_manager(void)
@@ -832,6 +848,9 @@ static struct device_manager *create_device_manager(void)
list_init( &manager->devices );
list_init( &manager->requests );
wine_rb_init( &manager->kernel_objects, compare_kernel_object );
@ -100,7 +92,7 @@ index 80904d33d0d..2a7727f05ae 100644
}
return manager;
}
@@ -1019,6 +1039,9 @@ DECL_HANDLER(get_next_device_request)
@@ -1021,6 +1040,9 @@ DECL_HANDLER(get_next_device_request)
/* we already own the object if it's only on manager queue */
if (irp->file) grab_object( irp );
manager->current_call = irp;
@ -111,5 +103,5 @@ index 80904d33d0d..2a7727f05ae 100644
else close_handle( current->process, reply->next );
}
--
2.33.0
2.35.1

View File

@ -1,17 +1,17 @@
From 1ad0cfe6a328fd4ffdbce2c61e1cc7c822391734 Mon Sep 17 00:00:00 2001
From 543476e8a53d41c69e89fbaa7d9cee8a48059944 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Fri, 15 Jun 2018 11:01:44 -0500
Subject: [PATCH] server: Create eventfd descriptors for timers.
---
server/timer.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
server/timer.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/server/timer.c b/server/timer.c
index 23d03aa3582..43b40a13032 100644
index f59902d5607..36645a2a8d2 100644
--- a/server/timer.c
+++ b/server/timer.c
@@ -36,6 +36,7 @@
@@ -35,6 +35,7 @@
#include "file.h"
#include "handle.h"
#include "request.h"
@ -19,7 +19,7 @@ index 23d03aa3582..43b40a13032 100644
static const WCHAR timer_name[] = {'T','i','m','e','r'};
@@ -62,10 +63,12 @@ struct timer
@@ -61,10 +62,12 @@ struct timer
struct thread *thread; /* thread that set the APC function */
client_ptr_t callback; /* callback APC function */
client_ptr_t arg; /* callback argument */
@ -32,7 +32,7 @@ index 23d03aa3582..43b40a13032 100644
static void timer_satisfied( struct object *obj, struct wait_queue_entry *entry );
static void timer_destroy( struct object *obj );
@@ -77,7 +80,7 @@ static const struct object_ops timer_ops =
@@ -76,7 +79,7 @@ static const struct object_ops timer_ops =
add_queue, /* add_queue */
remove_queue, /* remove_queue */
timer_signaled, /* signaled */
@ -41,7 +41,7 @@ index 23d03aa3582..43b40a13032 100644
timer_satisfied, /* satisfied */
no_signal, /* signal */
no_get_fd, /* get_fd */
@@ -112,6 +115,10 @@ static struct timer *create_timer( struct object *root, const struct unicode_str
@@ -111,6 +114,10 @@ static struct timer *create_timer( struct object *root, const struct unicode_str
timer->period = 0;
timer->timeout = NULL;
timer->thread = NULL;
@ -52,7 +52,7 @@ index 23d03aa3582..43b40a13032 100644
}
}
return timer;
@@ -185,6 +192,9 @@ static int set_timer( struct timer *timer, timeout_t expire, unsigned int period
@@ -182,6 +189,9 @@ static int set_timer( struct timer *timer, timeout_t expire, unsigned int period
{
period = 0; /* period doesn't make any sense for a manual timer */
timer->signaled = 0;
@ -62,7 +62,7 @@ index 23d03aa3582..43b40a13032 100644
}
timer->when = (expire <= 0) ? expire - monotonic_time : max( expire, current_time );
timer->period = period;
@@ -212,6 +222,13 @@ static int timer_signaled( struct object *obj, struct wait_queue_entry *entry )
@@ -209,6 +219,13 @@ static int timer_signaled( struct object *obj, struct wait_queue_entry *entry )
return timer->signaled;
}
@ -76,6 +76,14 @@ index 23d03aa3582..43b40a13032 100644
static void timer_satisfied( struct object *obj, struct wait_queue_entry *entry )
{
struct timer *timer = (struct timer *)obj;
@@ -223,6 +240,7 @@ static void timer_destroy( struct object *obj )
if (timer->timeout) remove_timeout_user( timer->timeout );
if (timer->thread) release_object( timer->thread );
+ if (do_esync()) close( timer->esync_fd );
}
/* create a timer */
--
2.20.1
2.35.1

View File

@ -1,14 +1,14 @@
From fa9bbbaa8630c4b259e287437a627e226c1c34da Mon Sep 17 00:00:00 2001
From 6adfd0593d10cc9ec8ed8364de167d40ee2098ce Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sat, 17 Oct 2020 19:13:16 -0500
Subject: [PATCH] server: Create esync file descriptors for console servers.
---
server/console.c | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
server/console.c | 37 +++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/server/console.c b/server/console.c
index e7c97e99579..98ac09efc3f 100644
index ae5d84f7a06..3f9c0ce356c 100644
--- a/server/console.c
+++ b/server/console.c
@@ -41,6 +41,7 @@
@ -67,7 +67,15 @@ index e7c97e99579..98ac09efc3f 100644
while (!list_empty( &server->read_queue ))
{
struct console_host_ioctl *call = LIST_ENTRY( list_head( &server->read_queue ), struct console_host_ioctl, entry );
@@ -897,6 +902,13 @@ static int console_server_signaled( struct object *obj, struct wait_queue_entry
@@ -877,6 +882,7 @@ static void console_server_destroy( struct object *obj )
assert( obj->ops == &console_server_ops );
disconnect_console_server( server );
if (server->fd) release_object( server->fd );
+ if (do_esync()) close( server->esync_fd );
}
static struct object *console_server_lookup_name( struct object *obj, struct unicode_str *name,
@@ -918,6 +924,13 @@ static int console_server_signaled( struct object *obj, struct wait_queue_entry
return !server->console || !list_empty( &server->queue );
}
@ -81,7 +89,7 @@ index e7c97e99579..98ac09efc3f 100644
static struct fd *console_server_get_fd( struct object* obj )
{
struct console_server *server = (struct console_server*)obj;
@@ -928,6 +940,10 @@ static struct object *create_console_server( void )
@@ -949,6 +962,10 @@ static struct object *create_console_server( void )
return NULL;
}
allow_fd_caching(server->fd);
@ -92,7 +100,7 @@ index e7c97e99579..98ac09efc3f 100644
return &server->obj;
}
@@ -1513,6 +1529,8 @@ DECL_HANDLER(get_next_console_request)
@@ -1562,6 +1579,8 @@ DECL_HANDLER(get_next_console_request)
/* set result of previous ioctl */
ioctl = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
list_remove( &ioctl->entry );
@ -101,7 +109,7 @@ index e7c97e99579..98ac09efc3f 100644
}
if (ioctl)
@@ -1598,6 +1616,8 @@ DECL_HANDLER(get_next_console_request)
@@ -1647,6 +1666,8 @@ DECL_HANDLER(get_next_console_request)
{
set_error( STATUS_PENDING );
}
@ -111,5 +119,5 @@ index e7c97e99579..98ac09efc3f 100644
release_object( server );
}
--
2.34.1
2.35.1