From: Rémi Bernon rbernon@codeweavers.com
--- server/async.c | 10 ++++++ server/atom.c | 1 + server/change.c | 2 +- server/clipboard.c | 1 + server/completion.c | 19 +++++++++- server/console.c | 47 ++++++++++++++++++++++++ server/debugger.c | 18 ++++++++++ server/device.c | 13 ++++++- server/directory.c | 2 ++ server/event.c | 18 ++++++++++ server/fd.c | 54 ++++++++++++++++++++-------- server/file.c | 4 +-- server/file.h | 3 +- server/handle.c | 1 + server/hook.c | 1 + server/mailslot.c | 6 ++-- server/mapping.c | 3 ++ server/mutex.c | 9 +++++ server/named_pipe.c | 10 +++--- server/object.c | 12 +++++++ server/object.h | 3 ++ server/process.c | 27 ++++++++++++++ server/queue.c | 10 ++++++ server/registry.c | 1 + server/request.c | 1 + server/semaphore.c | 9 +++++ server/serial.c | 2 +- server/signal.c | 1 + server/sock.c | 4 ++- server/symlink.c | 1 + server/thread.c | 87 +++++++++++++++++++++++++++++++++++++++++---- server/timer.c | 9 +++++ server/token.c | 1 + server/window.c | 1 + server/winstation.c | 2 ++ 35 files changed, 356 insertions(+), 37 deletions(-)
diff --git a/server/async.c b/server/async.c index 46ce1e3b6bc..50c4bcf58c2 100644 --- a/server/async.c +++ b/server/async.c @@ -66,6 +66,7 @@ struct async };
static void async_dump( struct object *obj, int verbose ); +static struct sync *async_get_sync( struct object *obj ); static int async_signaled( struct object *obj, struct wait_queue_entry *entry ); static void async_satisfied( struct object * obj, struct wait_queue_entry *entry ); static void async_destroy( struct object *obj ); @@ -85,6 +86,7 @@ static const struct object_ops async_ops = &no_type, /* type */ async_dump, /* dump */ no_get_fd, /* get_fd */ + async_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -110,6 +112,13 @@ static void async_dump( struct object *obj, int verbose ) fprintf( stderr, "Async thread=%p\n", async->thread ); }
+static struct sync *async_get_sync( struct object *obj ) +{ + struct async *async = (struct async *)obj; + assert( obj->ops == &async_ops ); + return &async->obj.sync; +} + static int async_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct async *async = (struct async *)obj; @@ -700,6 +709,7 @@ static const struct object_ops iosb_ops = &no_type, /* type */ iosb_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/atom.c b/server/atom.c index 04feea060fc..ef2ca3b360a 100644 --- a/server/atom.c +++ b/server/atom.c @@ -77,6 +77,7 @@ static const struct object_ops atom_table_ops = &no_type, /* type */ atom_table_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/change.c b/server/change.c index 31fa33f2e96..bdc7c7fe7d3 100644 --- a/server/change.c +++ b/server/change.c @@ -110,6 +110,7 @@ static const struct object_ops dir_ops = &file_type, /* type */ dir_dump, /* dump */ dir_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ dir_get_sd, /* get_sd */ dir_set_sd, /* set_sd */ @@ -1133,7 +1134,6 @@ struct object *create_dir_obj( struct fd *fd, unsigned int access, mode_t mode ) struct dir *dir;
if (!(dir = alloc_object( &dir_ops ))) return NULL; - dir->obj.sync.ops = &default_fd_sync_ops; list_init( &dir->change_records ); dir->filter = 0; dir->notified = 0; diff --git a/server/clipboard.c b/server/clipboard.c index 814d3c8f901..bc7855cd081 100644 --- a/server/clipboard.c +++ b/server/clipboard.c @@ -74,6 +74,7 @@ static const struct object_ops clipboard_ops = &no_type, /* type */ clipboard_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/completion.c b/server/completion.c index ad257a57f4d..052112866a4 100644 --- a/server/completion.c +++ b/server/completion.c @@ -80,6 +80,7 @@ struct completion };
static void completion_wait_dump( struct object*, int ); +static struct sync *completion_wait_get_sync( struct object * ); static int completion_wait_signaled( struct object *obj, struct wait_queue_entry *entry ); static void completion_wait_satisfied( struct object *obj, struct wait_queue_entry *entry ); static void completion_wait_destroy( struct object * ); @@ -99,6 +100,7 @@ static const struct object_ops completion_wait_ops = &no_type, /* type */ completion_wait_dump, /* dump */ no_get_fd, /* get_fd */ + completion_wait_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -115,7 +117,6 @@ static const struct object_ops completion_wait_ops = static void completion_wait_destroy( struct object *obj ) { struct completion_wait *wait = (struct completion_wait *)obj; - free( wait->msg ); }
@@ -127,6 +128,13 @@ static void completion_wait_dump( struct object *obj, int verbose ) fprintf( stderr, "Completion wait completion=%p\n", wait->completion ); }
+static struct sync *completion_wait_get_sync( struct object *obj ) +{ + struct completion_wait *wait = (struct completion_wait *)obj; + assert( obj->ops == &completion_wait_ops ); + return &wait->obj.sync; +} + static int completion_wait_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct completion_wait *wait = (struct completion_wait *)obj; @@ -158,6 +166,7 @@ static void completion_wait_satisfied( struct object *obj, struct wait_queue_ent }
static void completion_dump( struct object*, int ); +static struct sync *completion_get_sync( struct object * ); static int completion_signaled( struct object *obj, struct wait_queue_entry *entry ); static int completion_close_handle( struct object *obj, struct process *process, obj_handle_t handle ); static void completion_destroy( struct object * ); @@ -177,6 +186,7 @@ static const struct object_ops completion_ops = &completion_type, /* type */ completion_dump, /* dump */ no_get_fd, /* get_fd */ + completion_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -209,6 +219,13 @@ static void completion_dump( struct object *obj, int verbose ) fprintf( stderr, "Completion depth=%u\n", completion->depth ); }
+static struct sync *completion_get_sync( struct object *obj ) +{ + struct completion *completion = (struct completion *)obj; + assert( obj->ops == &completion_ops ); + return &completion->obj.sync; +} + static int completion_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct completion *completion = (struct completion *)obj; diff --git a/server/console.c b/server/console.c index e0fb85e8cc5..8ee1690551b 100644 --- a/server/console.c +++ b/server/console.c @@ -70,6 +70,7 @@ static void console_dump( struct object *obj, int verbose ); static void console_destroy( struct object *obj ); static int console_signaled( struct object *obj, struct wait_queue_entry *entry ); static struct fd *console_get_fd( struct object *obj ); +static struct sync *console_get_sync( struct object *obj ); static struct object *console_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr, struct object *root ); static struct object *console_open_file( struct object *obj, unsigned int access, @@ -91,6 +92,7 @@ static const struct object_ops console_ops = &file_type, /* type */ console_dump, /* dump */ console_get_fd, /* get_fd */ + console_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -152,6 +154,7 @@ static void console_server_dump( struct object *obj, int verbose ); static void console_server_destroy( struct object *obj ); static int console_server_signaled( struct object *obj, struct wait_queue_entry *entry ); static struct fd *console_server_get_fd( struct object *obj ); +static struct sync *console_server_get_sync( struct object *obj ); static struct object *console_server_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr, struct object *root ); static struct object *console_server_open_file( struct object *obj, unsigned int access, @@ -172,6 +175,7 @@ static const struct object_ops console_server_ops = &file_type, /* type */ console_server_dump, /* dump */ console_server_get_fd, /* get_fd */ + console_server_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -227,6 +231,7 @@ static void screen_buffer_dump( struct object *obj, int verbose ); static void screen_buffer_destroy( struct object *obj ); static int screen_buffer_signaled( struct object *obj, struct wait_queue_entry *entry ); static struct fd *screen_buffer_get_fd( struct object *obj ); +static struct sync *screen_buffer_get_sync( struct object *obj ); static struct object *screen_buffer_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options );
@@ -245,6 +250,7 @@ static const struct object_ops screen_buffer_ops = &file_type, /* type */ screen_buffer_dump, /* dump */ screen_buffer_get_fd, /* get_fd */ + screen_buffer_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -289,6 +295,7 @@ static const struct object_ops console_device_ops = &device_type, /* type */ console_device_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -315,6 +322,7 @@ static int console_input_signaled( struct object *obj, struct wait_queue_entry * static struct object *console_input_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options ); static struct fd *console_input_get_fd( struct object *obj ); +static struct sync *console_input_get_sync( struct object *obj ); static void console_input_destroy( struct object *obj );
static const struct sync_ops console_input_sync_ops = @@ -332,6 +340,7 @@ static const struct object_ops console_input_ops = &device_type, /* type */ console_input_dump, /* dump */ console_input_get_fd, /* get_fd */ + console_input_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -376,6 +385,7 @@ struct console_output static void console_output_dump( struct object *obj, int verbose ); static int console_output_signaled( struct object *obj, struct wait_queue_entry *entry ); static struct fd *console_output_get_fd( struct object *obj ); +static struct sync *console_output_get_sync( struct object *obj ); static struct object *console_output_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options ); static void console_output_destroy( struct object *obj ); @@ -395,6 +405,7 @@ static const struct object_ops console_output_ops = &device_type, /* type */ console_output_dump, /* dump */ console_output_get_fd, /* get_fd */ + console_output_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -448,6 +459,7 @@ static const struct object_ops console_connection_ops = &device_type, /* type */ console_connection_dump, /* dump */ console_connection_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -509,6 +521,13 @@ static struct fd *console_get_fd( struct object *obj ) return (struct fd *)grab_object( console->fd ); }
+static struct sync *console_get_sync( struct object *obj ) +{ + struct console *console = (struct console *)obj; + assert( obj->ops == &console_ops ); + return &console->obj.sync; +} + static enum server_fd_type console_get_fd_type( struct fd *fd ) { return FD_TYPE_CHAR; @@ -888,6 +907,13 @@ static struct fd *screen_buffer_get_fd( struct object *obj ) return NULL; }
+static struct sync *screen_buffer_get_sync( struct object *obj ) +{ + struct screen_buffer *screen_buffer = (struct screen_buffer *)obj; + assert( obj->ops == &screen_buffer_ops ); + return &screen_buffer->obj.sync; +} + static void console_server_dump( struct object *obj, int verbose ) { assert( obj->ops == &console_server_ops ); @@ -954,6 +980,13 @@ static struct fd *console_server_get_fd( struct object* obj ) return (struct fd *)grab_object( server->fd ); }
+static struct sync *console_server_get_sync( struct object *obj ) +{ + struct console_server *server = (struct console_server *)obj; + assert( obj->ops == &console_server_ops ); + return &server->obj.sync; +} + static struct object *console_server_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options ) { @@ -1449,6 +1482,13 @@ static struct fd *console_input_get_fd( struct object *obj ) return (struct fd *)grab_object( console_input->fd ); }
+static struct sync *console_input_get_sync( struct object *obj ) +{ + struct console_input *console_input = (struct console_input *)obj; + assert( obj->ops == &console_input_ops ); + return &console_input->obj.sync; +} + static struct object *console_input_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options ) { @@ -1520,6 +1560,13 @@ static struct fd *console_output_get_fd( struct object *obj ) return (struct fd *)grab_object( console_output->fd ); }
+static struct sync *console_output_get_sync( struct object *obj ) +{ + struct console_output *console_output = (struct console_output *)obj; + assert( obj->ops == &console_output_ops ); + return &console_output->obj.sync; +} + static struct object *console_output_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options ) { diff --git a/server/debugger.c b/server/debugger.c index 09c17712d17..8024556d77d 100644 --- a/server/debugger.c +++ b/server/debugger.c @@ -75,6 +75,7 @@ struct debug_obj
static void debug_event_dump( struct object *obj, int verbose ); +static struct sync *debug_event_get_sync( struct object *obj ); static int debug_event_signaled( struct object *obj, struct wait_queue_entry *entry ); static void debug_event_destroy( struct object *obj );
@@ -93,6 +94,7 @@ static const struct object_ops debug_event_ops = &no_type, /* type */ debug_event_dump, /* dump */ no_get_fd, /* get_fd */ + debug_event_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -107,6 +109,7 @@ static const struct object_ops debug_event_ops = };
static void debug_obj_dump( struct object *obj, int verbose ); +static struct sync *debug_obj_get_sync( struct object *obj ); static int debug_obj_signaled( struct object *obj, struct wait_queue_entry *entry ); static void debug_obj_destroy( struct object *obj );
@@ -125,6 +128,7 @@ static const struct object_ops debug_obj_ops = &debug_obj_type, /* type */ debug_obj_dump, /* dump */ no_get_fd, /* get_fd */ + debug_obj_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -307,6 +311,13 @@ static void debug_event_dump( struct object *obj, int verbose ) debug_event->sender, debug_event->data.code, debug_event->state ); }
+static struct sync *debug_event_get_sync( struct object *obj ) +{ + struct debug_event *debug_event = (struct debug_event *)obj; + assert( obj->ops == &debug_event_ops ); + return &debug_event->obj.sync; +} + static int debug_event_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct debug_event *debug_event = (struct debug_event *)obj; @@ -331,6 +342,13 @@ static void debug_obj_dump( struct object *obj, int verbose ) debug_obj->event_queue.next, debug_obj->event_queue.prev ); }
+static struct sync *debug_obj_get_sync( struct object *obj ) +{ + struct debug_obj *debug_obj = (struct debug_obj *)obj; + assert( obj->ops == &debug_obj_ops ); + return &debug_obj->obj.sync; +} + static int debug_obj_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct debug_obj *debug_obj = (struct debug_obj *)obj; diff --git a/server/device.c b/server/device.c index 13a6728939b..85e448447a0 100644 --- a/server/device.c +++ b/server/device.c @@ -64,6 +64,7 @@ static const struct object_ops irp_call_ops = &no_type, /* type */ irp_call_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -90,6 +91,7 @@ struct device_manager };
static void device_manager_dump( struct object *obj, int verbose ); +static struct sync *device_manager_get_sync( struct object *obj ); static int device_manager_signaled( struct object *obj, struct wait_queue_entry *entry ); static void device_manager_destroy( struct object *obj );
@@ -108,6 +110,7 @@ static const struct object_ops device_manager_ops = &no_type, /* type */ device_manager_dump, /* dump */ no_get_fd, /* get_fd */ + device_manager_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -160,6 +163,7 @@ static const struct object_ops device_ops = &device_type, /* type */ device_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -207,6 +211,7 @@ static const struct object_ops device_file_ops = &file_type, /* type */ device_file_dump, /* dump */ device_file_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -418,7 +423,6 @@ static struct object *device_open_file( struct object *obj, unsigned int access, struct unicode_str nt_name;
if (!(file = alloc_object( &device_file_ops ))) return NULL; - file->obj.sync.ops = &default_fd_sync_ops; file->device = (struct device *)grab_object( device ); file->closed = 0; list_init( &file->kernel_object ); @@ -765,6 +769,13 @@ static void device_manager_dump( struct object *obj, int verbose ) fprintf( stderr, "Device manager\n" ); }
+static struct sync *device_manager_get_sync( struct object *obj ) +{ + struct device_manager *manager = (struct device_manager *)obj; + assert( obj->ops == &device_manager_ops ); + return &manager->obj.sync; +} + static int device_manager_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct device_manager *manager = (struct device_manager *)obj; diff --git a/server/directory.c b/server/directory.c index 6abd7e5c238..70f62263d35 100644 --- a/server/directory.c +++ b/server/directory.c @@ -67,6 +67,7 @@ static const struct object_ops object_type_ops = &objtype_type, /* type */ object_type_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -112,6 +113,7 @@ static const struct object_ops directory_ops = &directory_type, /* type */ directory_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/event.c b/server/event.c index f9aa2d6244d..eeba7fcaf58 100644 --- a/server/event.c +++ b/server/event.c @@ -59,6 +59,7 @@ struct event };
static void event_dump( struct object *obj, int verbose ); +static struct sync *event_get_sync( struct object *obj ); static int event_signaled( struct object *obj, struct wait_queue_entry *entry ); static void event_satisfied( struct object *obj, struct wait_queue_entry *entry ); static int event_signal( struct object *obj, unsigned int access); @@ -79,6 +80,7 @@ static const struct object_ops event_ops = &event_type, /* type */ event_dump, /* dump */ no_get_fd, /* get_fd */ + event_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -113,6 +115,7 @@ struct keyed_event };
static void keyed_event_dump( struct object *obj, int verbose ); +static struct sync *keyed_event_get_sync( struct object *obj ); static int keyed_event_signaled( struct object *obj, struct wait_queue_entry *entry );
static const struct sync_ops keyed_event_sync_ops = @@ -130,6 +133,7 @@ static const struct object_ops keyed_event_ops = &keyed_event_type, /* type */ keyed_event_dump, /* dump */ no_get_fd, /* get_fd */ + keyed_event_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -197,6 +201,13 @@ static void event_dump( struct object *obj, int verbose ) event->manual_reset, event->signaled ); }
+static struct sync *event_get_sync( struct object *obj ) +{ + struct event *event = (struct event *)obj; + assert( obj->ops == &event_ops ); + return &event->obj.sync; +} + static int event_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct event *event = (struct event *)obj; @@ -258,6 +269,13 @@ static void keyed_event_dump( struct object *obj, int verbose ) fputs( "Keyed event\n", stderr ); }
+static struct sync *keyed_event_get_sync( struct object *obj ) +{ + struct keyed_event *event = (struct keyed_event *)obj; + assert( obj->ops == &keyed_event_ops ); + return &event->obj.sync; +} + static enum select_opcode matching_op( enum select_opcode op ) { return op ^ (SELECT_KEYED_EVENT_WAIT ^ SELECT_KEYED_EVENT_RELEASE); diff --git a/server/fd.c b/server/fd.c index b9366ee69e0..7859d9adbcd 100644 --- a/server/fd.c +++ b/server/fd.c @@ -157,14 +157,15 @@ struct fd };
static void fd_dump( struct object *obj, int verbose ); -static int default_fd_signaled( struct object *obj, struct wait_queue_entry *entry ); +static struct sync *fd_get_sync( struct object *obj ); +static int fd_signaled( struct object *obj, struct wait_queue_entry *entry ); static void fd_destroy( struct object *obj );
-const struct sync_ops default_fd_sync_ops = +const struct sync_ops fd_sync_ops = { add_queue, /* add_queue */ remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ + fd_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ }; @@ -175,6 +176,7 @@ static const struct object_ops fd_ops = &no_type, /* type */ fd_dump, /* dump */ no_get_fd, /* get_fd */ + fd_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -211,6 +213,7 @@ static const struct object_ops device_ops = &no_type, /* type */ device_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -246,6 +249,7 @@ static const struct object_ops inode_ops = &no_type, /* type */ inode_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -275,6 +279,7 @@ struct file_lock };
static void file_lock_dump( struct object *obj, int verbose ); +static struct sync *file_lock_get_sync( struct object *obj ); static int file_lock_signaled( struct object *obj, struct wait_queue_entry *entry );
static const struct sync_ops file_lock_sync_ops = @@ -292,6 +297,7 @@ static const struct object_ops file_lock_ops = &no_type, /* type */ file_lock_dump, /* dump */ no_get_fd, /* get_fd */ + file_lock_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -1235,6 +1241,13 @@ static void file_lock_dump( struct object *obj, int verbose ) fprintf( stderr, "\n" ); }
+static struct sync *file_lock_get_sync( struct object *obj ) +{ + struct file_lock *lock = (struct file_lock *)obj; + assert( obj->ops == &file_lock_ops ); + return &lock->obj.sync; +} + static int file_lock_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct file_lock *lock = (struct file_lock *)obj; @@ -1560,6 +1573,12 @@ static void fd_dump( struct object *obj, int verbose ) fprintf( stderr, "\n" ); }
+static struct sync *fd_get_sync( struct object *obj ) +{ + struct fd *fd = (struct fd *)obj; + return &fd->obj.sync; +} + static void fd_destroy( struct object *obj ) { struct fd *fd = (struct fd *)obj; @@ -1679,10 +1698,10 @@ static inline void unmount_fd( struct fd *fd ) /* allocate an fd object, without setting the unix fd yet */ static struct fd *alloc_fd_object(void) { - struct fd *fd = alloc_object( &fd_ops ); - - if (!fd) return NULL; + struct fd *fd;
+ if (!(fd = alloc_object( &fd_ops ))) return NULL; + fd->obj.sync.ops = &fd_sync_ops; fd->fd_ops = NULL; fd->user = NULL; fd->inode = NULL; @@ -1719,10 +1738,10 @@ static struct fd *alloc_fd_object(void) /* allocate a pseudo fd object, for objects that need to behave like files but don't have a unix fd */ struct fd *alloc_pseudo_fd( const struct fd_ops *fd_user_ops, struct object *user, unsigned int options ) { - struct fd *fd = alloc_object( &fd_ops ); - - if (!fd) return NULL; + struct fd *fd;
+ if (!(fd = alloc_object( &fd_ops ))) return NULL; + fd->obj.sync.ops = &fd_sync_ops; fd->fd_ops = fd_user_ops; fd->user = user; fd->inode = NULL; @@ -2152,7 +2171,7 @@ void set_fd_signaled( struct fd *fd, int signaled ) { if (fd->comp_flags & FILE_SKIP_SET_EVENT_ON_HANDLE) return; fd->signaled = signaled; - if (signaled) wake_up( fd->user, 0 ); + if (signaled) wake_up( &fd->obj, 0 ); }
/* check if events are pending and if yes return which one(s) */ @@ -2169,13 +2188,20 @@ int check_fd_events( struct fd *fd, int events ) return pfd.revents; }
-/* default signaled() routine for objects that poll() on an fd */ -static int default_fd_signaled( struct object *obj, struct wait_queue_entry *entry ) +static int fd_signaled( struct object *obj, struct wait_queue_entry *entry ) +{ + struct fd *fd = (struct fd *)obj; + assert( obj->ops == &fd_ops ); + return fd->signaled; +} + +/* default get_sync() routine for objects that poll() on an fd */ +struct sync *default_fd_get_sync( struct object *obj ) { struct fd *fd = get_obj_fd( obj ); - int ret = fd->signaled; + struct sync *sync = &fd->obj.sync; release_object( fd ); - return ret; + return sync; }
int default_fd_get_poll_events( struct fd *fd ) diff --git a/server/file.c b/server/file.c index 666b1a6f55e..d1d695b934c 100644 --- a/server/file.c +++ b/server/file.c @@ -92,6 +92,7 @@ static const struct object_ops file_ops = &file_type, /* type */ file_dump, /* dump */ file_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ file_get_sd, /* get_sd */ file_set_sd, /* set_sd */ @@ -140,7 +141,6 @@ struct file *create_file_for_fd( int fd, unsigned int access, unsigned int shari close( fd ); return NULL; } - file->obj.sync.ops = &default_fd_sync_ops; file->mode = st.st_mode; file->access = default_map_access( &file->obj, access ); list_init( &file->kernel_object ); @@ -168,7 +168,6 @@ struct file *create_file_for_fd_obj( struct fd *fd, unsigned int access, unsigne
if ((file = alloc_object( &file_ops ))) { - file->obj.sync.ops = &default_fd_sync_ops; file->mode = st.st_mode; file->access = default_map_access( &file->obj, access ); list_init( &file->kernel_object ); @@ -187,7 +186,6 @@ static struct object *create_file_obj( struct fd *fd, unsigned int access, mode_ struct file *file;
if (!(file = alloc_object( &file_ops ))) return NULL; - file->obj.sync.ops = &default_fd_sync_ops; file->access = access; file->mode = mode; file->uid = ~(uid_t)0; diff --git a/server/file.h b/server/file.h index 66a67ec4a16..06622c40783 100644 --- a/server/file.h +++ b/server/file.h @@ -109,6 +109,7 @@ extern void set_fd_signaled( struct fd *fd, int signaled ); extern char *dup_fd_name( struct fd *root, const char *name ) __WINE_DEALLOC(free) __WINE_MALLOC; extern void get_nt_name( struct fd *fd, struct unicode_str *name );
+extern struct sync *default_fd_get_sync( struct object *obj ); extern int default_fd_get_poll_events( struct fd *fd ); extern void default_poll_event( struct fd *fd, int event ); extern void fd_cancel_async( struct fd *fd, struct async *async ); @@ -132,8 +133,6 @@ extern void remove_process_locks( struct process *process );
static inline struct fd *get_obj_fd( struct object *obj ) { return obj->ops->get_fd( obj ); }
-extern const struct sync_ops default_fd_sync_ops; - /* timeout functions */
struct timeout_user; diff --git a/server/handle.c b/server/handle.c index 39dad955ed2..38d9f87b5a3 100644 --- a/server/handle.c +++ b/server/handle.c @@ -124,6 +124,7 @@ static const struct object_ops handle_table_ops = &no_type, /* type */ handle_table_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/hook.c b/server/hook.c index 45e185f9896..2cc321310f4 100644 --- a/server/hook.c +++ b/server/hook.c @@ -79,6 +79,7 @@ static const struct object_ops hook_table_ops = &no_type, /* type */ hook_table_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/mailslot.c b/server/mailslot.c index 3d338b06e71..5970af120f5 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -79,6 +79,7 @@ static const struct object_ops mailslot_ops = &file_type, /* type */ mailslot_dump, /* dump */ mailslot_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ mailslot_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -135,6 +136,7 @@ static const struct object_ops mail_writer_ops = &file_type, /* type */ mail_writer_dump, /* dump */ mail_writer_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ mail_writer_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -195,6 +197,7 @@ static const struct object_ops mailslot_device_ops = &device_type, /* type */ mailslot_device_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -220,6 +223,7 @@ static const struct object_ops mailslot_device_file_ops = &file_type, /* type */ mailslot_device_file_dump, /* dump */ mailslot_device_file_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -463,7 +467,6 @@ static struct object *mailslot_device_open_file( struct object *obj, unsigned in struct mailslot_device_file *file;
if (!(file = alloc_object( &mailslot_device_file_ops ))) return NULL; - file->obj.sync.ops = &default_fd_sync_ops; file->device = (struct mailslot_device *)grab_object( obj ); if (!(file->fd = alloc_pseudo_fd( &mailslot_device_fd_ops, obj, options ))) { @@ -539,7 +542,6 @@ static struct mailslot *create_mailslot( struct object *root, struct mailslot *mailslot;
if (!(mailslot = create_named_object( root, &mailslot_ops, name, attr & ~OBJ_OPENIF, sd ))) return NULL; - mailslot->obj.sync.ops = &default_fd_sync_ops; mailslot->fd = NULL; mailslot->max_msgsize = max_msgsize; mailslot->read_timeout = read_timeout; diff --git a/server/mapping.c b/server/mapping.c index a755577a77f..6fb2d4f3a01 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -65,6 +65,7 @@ static const struct object_ops ranges_ops = &no_type, /* type */ ranges_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -96,6 +97,7 @@ static const struct object_ops shared_map_ops = &no_type, /* type */ shared_map_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -164,6 +166,7 @@ static const struct object_ops mapping_ops = &mapping_type, /* type */ mapping_dump, /* dump */ mapping_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/mutex.c b/server/mutex.c index 5b7184e6913..f2ddbe9cc1e 100644 --- a/server/mutex.c +++ b/server/mutex.c @@ -60,6 +60,7 @@ struct mutex };
static void mutex_dump( struct object *obj, int verbose ); +static struct sync *mutex_get_sync( struct object *obj ); static int mutex_signaled( struct object *obj, struct wait_queue_entry *entry ); static void mutex_satisfied( struct object *obj, struct wait_queue_entry *entry ); static void mutex_destroy( struct object *obj ); @@ -80,6 +81,7 @@ static const struct object_ops mutex_ops = &mutex_type, /* type */ mutex_dump, /* dump */ no_get_fd, /* get_fd */ + mutex_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -158,6 +160,13 @@ static void mutex_dump( struct object *obj, int verbose ) fprintf( stderr, "Mutex count=%u owner=%p\n", mutex->count, mutex->owner ); }
+static struct sync *mutex_get_sync( struct object *obj ) +{ + struct mutex *mutex = (struct mutex *)obj; + assert( obj->ops == &mutex_ops ); + return &mutex->obj.sync; +} + static int mutex_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct mutex *mutex = (struct mutex *)obj; diff --git a/server/named_pipe.c b/server/named_pipe.c index a281e908fe6..88f17f74713 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -117,6 +117,7 @@ static const struct object_ops named_pipe_ops = &no_type, /* type */ named_pipe_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ named_pipe_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -160,6 +161,7 @@ static const struct object_ops pipe_server_ops = &file_type, /* type */ pipe_server_dump, /* dump */ pipe_end_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ pipe_end_get_sd, /* get_sd */ pipe_end_set_sd, /* set_sd */ @@ -199,6 +201,7 @@ static const struct object_ops pipe_client_ops = &file_type, /* type */ pipe_client_dump, /* dump */ pipe_end_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ pipe_end_get_sd, /* get_sd */ pipe_end_set_sd, /* set_sd */ @@ -241,6 +244,7 @@ static const struct object_ops named_pipe_device_ops = &device_type, /* type */ named_pipe_device_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -267,6 +271,7 @@ static const struct object_ops named_pipe_device_file_ops = &file_type, /* type */ named_pipe_device_file_dump, /* dump */ named_pipe_device_file_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -312,6 +317,7 @@ static const struct object_ops named_pipe_dir_ops = &file_type, /* type */ named_pipe_dir_dump, /* dump */ named_pipe_dir_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -527,7 +533,6 @@ static struct object *named_pipe_device_lookup_name( struct object *obj, struct struct named_pipe_device_file *dir;
if (!(dir = alloc_object( &named_pipe_dir_ops ))) return NULL; - dir->obj.sync.ops = &default_fd_sync_ops; dir->fd = NULL; /* defer alloc_pseudo_fd() until after we have options */ dir->device = (struct named_pipe_device *)grab_object( obj );
@@ -546,7 +551,6 @@ static struct object *named_pipe_device_open_file( struct object *obj, unsigned struct named_pipe_device_file *file;
if (!(file = alloc_object( &named_pipe_device_file_ops ))) return NULL; - file->obj.sync.ops = &default_fd_sync_ops; file->device = (struct named_pipe_device *)grab_object( obj ); if (!(file->fd = alloc_pseudo_fd( &named_pipe_device_fd_ops, obj, options ))) { @@ -1378,7 +1382,6 @@ static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned struct pipe_server *server;
if (!(server = alloc_object( &pipe_server_ops ))) return NULL; - server->pipe_end.obj.sync.ops = &default_fd_sync_ops; server->options = options; init_pipe_end( &server->pipe_end, pipe, pipe_flags, pipe->insize ); server->pipe_end.state = FILE_PIPE_LISTENING_STATE; @@ -1402,7 +1405,6 @@ static struct pipe_end *create_pipe_client( struct named_pipe *pipe, data_size_t struct pipe_end *client;
if (!(client = alloc_object( &pipe_client_ops ))) return NULL; - client->obj.sync.ops = &default_fd_sync_ops; init_pipe_end( client, pipe, 0, buffer_size ); client->state = FILE_PIPE_CONNECTED_STATE; client->client_pid = get_process_id( current->process ); diff --git a/server/object.c b/server/object.c index 70f83870bf7..302bbb53523 100644 --- a/server/object.c +++ b/server/object.c @@ -106,6 +106,7 @@ static const struct object_ops apc_reserve_ops = &apc_reserve_type, /* type */ dump_reserve, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -125,6 +126,7 @@ static const struct object_ops completion_reserve_ops = &completion_reserve_type, /* type */ dump_reserve, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -294,6 +296,11 @@ static const struct sync_ops no_sync_ops = no_signal, /* signal */ };
+static struct sync no_sync = +{ + &no_sync_ops, +}; + /* allocate and initialize an object */ void *alloc_object( const struct object_ops *ops ) { @@ -639,6 +646,11 @@ struct fd *no_get_fd( struct object *obj ) return NULL; }
+struct sync *no_get_sync( struct object *obj ) +{ + return &no_sync; +} + unsigned int default_map_access( struct object *obj, unsigned int access ) { return map_access( access, &obj->ops->type->mapping ); diff --git a/server/object.h b/server/object.h index 199ce98ed65..3db4f3d56cb 100644 --- a/server/object.h +++ b/server/object.h @@ -94,6 +94,8 @@ struct object_ops void (*dump)(struct object *,int); /* return an fd object that can be used to read/write from the object */ struct fd *(*get_fd)(struct object *); + /* return a sync that can be used to wait/signal the object */ + struct sync *(*get_sync)(struct object *); /* map access rights to the specific rights for this object */ unsigned int (*map_access)(struct object *, unsigned int); /* returns the security descriptor of the object */ @@ -181,6 +183,7 @@ extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry ); extern void no_satisfied( struct object *obj, struct wait_queue_entry *entry ); extern int no_signal( struct object *obj, unsigned int access ); extern struct fd *no_get_fd( struct object *obj ); +extern struct sync *no_get_sync( struct object *obj ); extern unsigned int default_map_access( struct object *obj, unsigned int access ); extern struct security_descriptor *default_get_sd( struct object *obj ); extern int default_set_sd( struct object *obj, const struct security_descriptor *sd, unsigned int set_info ); diff --git a/server/process.c b/server/process.c index 19ece8c56c4..eac2df227c9 100644 --- a/server/process.c +++ b/server/process.c @@ -89,6 +89,7 @@ struct type_descr process_type = };
static void process_dump( struct object *obj, int verbose ); +static struct sync *process_get_sync( struct object *obj ); static int process_signaled( struct object *obj, struct wait_queue_entry *entry ); static unsigned int process_map_access( struct object *obj, unsigned int access ); static struct security_descriptor *process_get_sd( struct object *obj ); @@ -112,6 +113,7 @@ static const struct object_ops process_ops = &process_type, /* type */ process_dump, /* dump */ no_get_fd, /* get_fd */ + process_get_sync, /* get_sync */ process_map_access, /* map_access */ process_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -149,6 +151,7 @@ struct startup_info };
static void startup_info_dump( struct object *obj, int verbose ); +static struct sync *startup_info_get_sync( struct object *obj ); static int startup_info_signaled( struct object *obj, struct wait_queue_entry *entry ); static void startup_info_destroy( struct object *obj );
@@ -167,6 +170,7 @@ static const struct object_ops startup_info_ops = &no_type, /* type */ startup_info_dump, /* dump */ no_get_fd, /* get_fd */ + startup_info_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -197,6 +201,7 @@ struct type_descr job_type = };
static void job_dump( struct object *obj, int verbose ); +static struct sync *job_get_sync( struct object *obj ); static int job_signaled( struct object *obj, struct wait_queue_entry *entry ); static int job_close_handle( struct object *obj, struct process *process, obj_handle_t handle ); static void job_destroy( struct object *obj ); @@ -232,6 +237,7 @@ static const struct object_ops job_ops = &job_type, /* type */ job_dump, /* dump */ no_get_fd, /* get_fd */ + job_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -462,6 +468,13 @@ static void job_dump( struct object *obj, int verbose ) list_count(&job->process_list), list_count(&job->child_job_list), job->parent ); }
+static struct sync *job_get_sync( struct object *obj ) +{ + struct job *job = (struct job *)obj; + assert( obj->ops == &job_ops ); + return &job->obj.sync; +} + static int job_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct job *job = (struct job *)obj; @@ -809,6 +822,13 @@ static void process_dump( struct object *obj, int verbose ) fprintf( stderr, "Process id=%04x handles=%p\n", process->id, process->handles ); }
+static struct sync *process_get_sync( struct object *obj ) +{ + struct process *process = (struct process *)obj; + assert( obj->ops == &process_ops ); + return &process->obj.sync; +} + static int process_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct process *process = (struct process *)obj; @@ -899,6 +919,13 @@ static void startup_info_dump( struct object *obj, int verbose ) fputc( '\n', stderr ); }
+static struct sync *startup_info_get_sync( struct object *obj ) +{ + struct startup_info *info = (struct startup_info *)obj; + assert( obj->ops == &startup_info_ops ); + return &info->obj.sync; +} + static int startup_info_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct startup_info *info = (struct startup_info *)obj; diff --git a/server/queue.c b/server/queue.c index 7146ee51a2c..f607fafa882 100644 --- a/server/queue.c +++ b/server/queue.c @@ -147,6 +147,7 @@ struct hotkey };
static void msg_queue_dump( struct object *obj, int verbose ); +static struct sync *msg_queue_get_sync( struct object *obj ); static int msg_queue_add_queue( struct object *obj, struct wait_queue_entry *entry ); static void msg_queue_remove_queue( struct object *obj, struct wait_queue_entry *entry ); static int msg_queue_signaled( struct object *obj, struct wait_queue_entry *entry ); @@ -172,6 +173,7 @@ static const struct object_ops msg_queue_ops = &no_type, /* type */ msg_queue_dump, /* dump */ no_get_fd, /* get_fd */ + msg_queue_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -204,6 +206,7 @@ static const struct object_ops thread_input_ops = &no_type, /* type */ thread_input_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -1305,6 +1308,13 @@ static void msg_queue_dump( struct object *obj, int verbose ) queue_shm->wake_bits, queue_shm->wake_mask ); }
+static struct sync *msg_queue_get_sync( struct object *obj ) +{ + struct msg_queue *queue = (struct msg_queue *)obj; + assert( obj->ops == &msg_queue_ops ); + return &queue->obj.sync; +} + static int msg_queue_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct msg_queue *queue = (struct msg_queue *)obj; diff --git a/server/registry.c b/server/registry.c index bd80d3e7399..169833f53e6 100644 --- a/server/registry.c +++ b/server/registry.c @@ -178,6 +178,7 @@ static const struct object_ops key_ops = &key_type, /* type */ key_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ key_map_access, /* map_access */ key_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/request.c b/server/request.c index 474750523bf..83ecdff286e 100644 --- a/server/request.c +++ b/server/request.c @@ -87,6 +87,7 @@ static const struct object_ops master_socket_ops = &no_type, /* type */ master_socket_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/semaphore.c b/server/semaphore.c index 7c7de0f77f7..3ac9ff23a2d 100644 --- a/server/semaphore.c +++ b/server/semaphore.c @@ -58,6 +58,7 @@ struct semaphore };
static void semaphore_dump( struct object *obj, int verbose ); +static struct sync *semaphore_get_sync( struct object *obj ); static int semaphore_signaled( struct object *obj, struct wait_queue_entry *entry ); static void semaphore_satisfied( struct object *obj, struct wait_queue_entry *entry ); static int semaphore_signal( struct object *obj, unsigned int access ); @@ -77,6 +78,7 @@ static const struct object_ops semaphore_ops = &semaphore_type, /* type */ semaphore_dump, /* dump */ no_get_fd, /* get_fd */ + semaphore_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -144,6 +146,13 @@ static void semaphore_dump( struct object *obj, int verbose ) fprintf( stderr, "Semaphore count=%d max=%d\n", sem->count, sem->max ); }
+static struct sync *semaphore_get_sync( struct object *obj ) +{ + struct semaphore *semaphore = (struct semaphore *)obj; + assert( obj->ops == &semaphore_ops ); + return &semaphore->obj.sync; +} + static int semaphore_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct semaphore *sem = (struct semaphore *)obj; diff --git a/server/serial.c b/server/serial.c index aedc962174a..5f29dff7948 100644 --- a/server/serial.c +++ b/server/serial.c @@ -89,6 +89,7 @@ static const struct object_ops serial_ops = &file_type, /* type */ serial_dump, /* dump */ serial_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -132,7 +133,6 @@ struct object *create_serial( struct fd *fd ) struct serial *serial;
if (!(serial = alloc_object( &serial_ops ))) return NULL; - serial->obj.sync.ops = &default_fd_sync_ops; serial->read_timer = NULL; serial->eventmask = 0; serial->pending_write = 0; diff --git a/server/signal.c b/server/signal.c index 8016c507367..6b18d5f2412 100644 --- a/server/signal.c +++ b/server/signal.c @@ -60,6 +60,7 @@ static const struct object_ops handler_ops = &no_type, /* type */ handler_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/sock.c b/server/sock.c index 4dd973ae7d8..fc7a181534e 100644 --- a/server/sock.c +++ b/server/sock.c @@ -484,6 +484,7 @@ static const struct object_ops sock_ops = &file_type, /* type */ sock_dump, /* dump */ sock_get_fd, /* get_fd */ + default_fd_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -1777,7 +1778,6 @@ static struct sock *create_socket(void) struct sock *sock;
if (!(sock = alloc_object( &sock_ops ))) return NULL; - sock->obj.sync.ops = &default_fd_sync_ops; sock->fd = NULL; sock->state = SOCK_UNCONNECTED; sock->mask = 0; @@ -3689,6 +3689,7 @@ static const struct object_ops ifchange_ops = &no_type, /* type */ ifchange_dump, /* dump */ ifchange_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -3905,6 +3906,7 @@ static const struct object_ops socket_device_ops = &device_type, /* type */ socket_device_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/symlink.c b/server/symlink.c index 125130fc90c..391facc355f 100644 --- a/server/symlink.c +++ b/server/symlink.c @@ -69,6 +69,7 @@ static const struct object_ops symlink_ops = &symlink_type, /* type */ symlink_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/thread.c b/server/thread.c index ea4432ec6a6..5100045b7f2 100644 --- a/server/thread.c +++ b/server/thread.c @@ -94,6 +94,7 @@ struct thread_apc };
static void dump_thread_apc( struct object *obj, int verbose ); +static struct sync *thread_apc_get_sync( struct object *obj ); static int thread_apc_signaled( struct object *obj, struct wait_queue_entry *entry ); static void thread_apc_destroy( struct object *obj ); static void clear_apc_queue( struct list *queue ); @@ -113,6 +114,7 @@ static const struct object_ops thread_apc_ops = &no_type, /* type */ dump_thread_apc, /* dump */ no_get_fd, /* get_fd */ + thread_apc_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -142,6 +144,7 @@ struct context static const unsigned int system_flags = SERVER_CTX_DEBUG_REGISTERS;
static void dump_context( struct object *obj, int verbose ); +static struct sync *context_get_sync( struct object *obj ); static int context_signaled( struct object *obj, struct wait_queue_entry *entry );
static const struct sync_ops context_sync_ops = @@ -159,6 +162,7 @@ static const struct object_ops context_ops = &no_type, /* type */ dump_context, /* dump */ no_get_fd, /* get_fd */ + context_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -191,6 +195,7 @@ struct type_descr thread_type = };
static void dump_thread( struct object *obj, int verbose ); +static struct sync *thread_get_sync( struct object *obj ); static int thread_signaled( struct object *obj, struct wait_queue_entry *entry ); static unsigned int thread_map_access( struct object *obj, unsigned int access ); static void thread_poll_event( struct fd *fd, int event ); @@ -212,6 +217,7 @@ static const struct object_ops thread_ops = &thread_type, /* type */ dump_thread, /* dump */ no_get_fd, /* get_fd */ + thread_get_sync, /* get_sync */ thread_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -459,6 +465,13 @@ static void dump_context( struct object *obj, int verbose ) context->regs[CTX_NATIVE].flags, context->regs[CTX_WOW].flags ); }
+static struct sync *context_get_sync( struct object *obj ) +{ + struct context *context = (struct context *)obj; + assert( obj->ops == &context_ops ); + return &context->obj.sync; +} +
static int context_signaled( struct object *obj, struct wait_queue_entry *entry ) { @@ -647,6 +660,13 @@ static void dump_thread( struct object *obj, int verbose ) thread->id, thread->unix_pid, thread->unix_tid, thread->state ); }
+static struct sync *thread_get_sync( struct object *obj ) +{ + struct thread *thread = (struct thread *)obj; + assert( obj->ops == &thread_ops ); + return &thread->obj.sync; +} + static int thread_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct thread *mythread = (struct thread *)obj; @@ -669,6 +689,13 @@ static void dump_thread_apc( struct object *obj, int verbose ) fprintf( stderr, "APC owner=%p type=%u\n", apc->owner, apc->call.type ); }
+static struct sync *thread_apc_get_sync( struct object *obj ) +{ + struct thread_apc *apc = (struct thread_apc *)obj; + assert( obj->ops == &thread_apc_ops ); + return &apc->obj.sync; +} + static int thread_apc_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct thread_apc *apc = (struct thread_apc *)obj; @@ -975,6 +1002,36 @@ void set_wait_status( struct wait_queue_entry *entry, int status ) entry->wait->status = status; }
+static void sync_satisfied( struct sync *sync, struct wait_queue_entry *entry ) +{ + struct object *obj = CONTAINING_RECORD( sync, struct object, sync ); + sync->ops->satisfied( obj, entry ); +} + +static void sync_remove_queue( struct sync *sync, struct wait_queue_entry *entry ) +{ + struct object *obj = CONTAINING_RECORD( sync, struct object, sync ); + sync->ops->remove_queue( obj, entry ); +} + +static int sync_add_queue( struct sync *sync, struct wait_queue_entry *entry ) +{ + struct object *obj = CONTAINING_RECORD( sync, struct object, sync ); + return sync->ops->add_queue( obj, entry ); +} + +static int sync_signaled( struct sync *sync, struct wait_queue_entry *entry ) +{ + struct object *obj = CONTAINING_RECORD( sync, struct object, sync ); + return sync->ops->signaled( obj, entry ); +} + +static int sync_signal( struct sync *sync, unsigned int access ) +{ + struct object *obj = CONTAINING_RECORD( sync, struct object, sync ); + return sync->ops->signal( obj, access ); +} + /* finish waiting */ static unsigned int end_wait( struct thread *thread, unsigned int status ) { @@ -991,18 +1048,26 @@ static unsigned int end_wait( struct thread *thread, unsigned int status ) if (wait->select == SELECT_WAIT_ALL) { for (i = 0, entry = wait->queues; i < wait->count; i++, entry++) - entry->obj->sync.ops->satisfied( entry->obj, entry ); + { + struct sync *sync = entry->obj->ops->get_sync( entry->obj ); + sync_satisfied( sync, entry ); + } } else { + struct sync *sync; entry = wait->queues + status; - entry->obj->sync.ops->satisfied( entry->obj, entry ); + sync = entry->obj->ops->get_sync( entry->obj ); + sync_satisfied( sync, entry ); } status = wait->status; if (wait->abandoned) status += STATUS_ABANDONED_WAIT_0; } for (i = 0, entry = wait->queues; i < wait->count; i++, entry++) - entry->obj->sync.ops->remove_queue( entry->obj, entry ); + { + struct sync *sync = entry->obj->ops->get_sync( entry->obj ); + sync_remove_queue( sync, entry ); + } if (wait->user) remove_timeout_user( wait->user ); free( wait ); return status; @@ -1031,8 +1096,9 @@ static int wait_on( const union select_op *select_op, unsigned int count, struct for (i = 0, entry = wait->queues; i < count; i++, entry++) { struct object *obj = objects[i]; + struct sync *sync = obj->ops->get_sync( obj ); entry->wait = wait; - if (!obj->sync.ops->add_queue( obj, entry )) + if (!sync_add_queue( sync, entry )) { wait->count = i; end_wait( current, get_error() ); @@ -1086,13 +1152,19 @@ static int check_wait( struct thread *thread ) /* Note: we must check them all anyway, as some objects may * want to do something when signaled, even if others are not */ for (i = 0, entry = wait->queues; i < wait->count; i++, entry++) - not_ok |= !entry->obj->sync.ops->signaled( entry->obj, entry ); + { + struct sync *sync = entry->obj->ops->get_sync( entry->obj ); + not_ok |= !sync_signaled( sync, entry ); + } if (!not_ok) return STATUS_WAIT_0; } else { for (i = 0, entry = wait->queues; i < wait->count; i++, entry++) - if (entry->obj->sync.ops->signaled( entry->obj, entry )) return i; + { + struct sync *sync = entry->obj->ops->get_sync( entry->obj ); + if (sync_signaled( sync, entry )) return i; + } }
if ((wait->flags & SELECT_ALERTABLE) && !list_empty(&thread->user_apc)) return STATUS_USER_APC; @@ -1208,7 +1280,8 @@ static int signal_object( obj_handle_t handle ) obj = get_handle_obj( current->process, handle, 0, NULL ); if (obj) { - ret = obj->sync.ops->signal( obj, get_handle_access( current->process, handle )); + struct sync *sync = obj->ops->get_sync( obj ); + ret = sync_signal( sync, get_handle_access( current->process, handle ) ); release_object( obj ); } return ret; diff --git a/server/timer.c b/server/timer.c index c82845cf80f..50cb7a618e5 100644 --- a/server/timer.c +++ b/server/timer.c @@ -64,6 +64,7 @@ struct timer };
static void timer_dump( struct object *obj, int verbose ); +static struct sync *timer_get_sync( struct object *obj ); static int timer_signaled( struct object *obj, struct wait_queue_entry *entry ); static void timer_satisfied( struct object *obj, struct wait_queue_entry *entry ); static void timer_destroy( struct object *obj ); @@ -83,6 +84,7 @@ static const struct object_ops timer_ops = &timer_type, /* type */ timer_dump, /* dump */ no_get_fd, /* get_fd */ + timer_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -206,6 +208,13 @@ static void timer_dump( struct object *obj, int verbose ) timer->manual, get_timeout_str(timeout), timer->period ); }
+static struct sync *timer_get_sync( struct object *obj ) +{ + struct timer *timer = (struct timer *)obj; + assert( obj->ops == &timer_ops ); + return &timer->obj.sync; +} + static int timer_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct timer *timer = (struct timer *)obj; diff --git a/server/token.c b/server/token.c index e7a975ae793..4f90a673f8e 100644 --- a/server/token.c +++ b/server/token.c @@ -143,6 +143,7 @@ static const struct object_ops token_ops = &token_type, /* type */ token_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ token_set_sd, /* set_sd */ diff --git a/server/window.c b/server/window.c index da215ab5b78..1d8bf258d02 100644 --- a/server/window.c +++ b/server/window.c @@ -105,6 +105,7 @@ static const struct object_ops window_ops = &no_type, /* type */ window_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ diff --git a/server/winstation.c b/server/winstation.c index 5b33abb257f..019c2fc810c 100644 --- a/server/winstation.c +++ b/server/winstation.c @@ -74,6 +74,7 @@ static const struct object_ops winstation_ops = &winstation_type, /* type */ winstation_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ @@ -109,6 +110,7 @@ static const struct object_ops desktop_ops = &desktop_type, /* type */ desktop_dump, /* dump */ no_get_fd, /* get_fd */ + no_get_sync, /* get_sync */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */