From: Rémi Bernon rbernon@codeweavers.com
--- server/async.c | 19 +++++------ server/atom.c | 5 --- server/change.c | 11 ++---- server/clipboard.c | 5 --- server/completion.c | 26 +++++++++----- server/console.c | 83 +++++++++++++++++++++++++-------------------- server/debugger.c | 26 +++++++++----- server/device.c | 30 ++++++---------- server/directory.c | 10 ------ server/event.c | 26 +++++++++----- server/fd.c | 40 +++++++++++----------- server/file.c | 13 +++---- server/file.h | 4 ++- server/handle.c | 5 --- server/hook.c | 5 --- server/mailslot.c | 23 ++----------- server/mapping.c | 15 -------- server/mutex.c | 13 ++++--- server/named_pipe.c | 49 +++++--------------------- server/object.c | 20 +++++------ server/object.h | 27 ++++++++++----- server/process.c | 39 ++++++++++++++------- server/queue.c | 18 +++++----- server/registry.c | 5 --- server/request.c | 5 --- server/semaphore.c | 13 ++++--- server/serial.c | 7 +--- server/signal.c | 5 --- server/sock.c | 16 +-------- server/symlink.c | 5 --- server/thread.c | 53 ++++++++++++++++++----------- server/timer.c | 13 ++++--- server/token.c | 5 --- server/window.c | 5 --- server/winstation.c | 10 ------ 35 files changed, 288 insertions(+), 366 deletions(-)
diff --git a/server/async.c b/server/async.c index d2d929c9709..46ce1e3b6bc 100644 --- a/server/async.c +++ b/server/async.c @@ -70,16 +70,20 @@ 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 );
-static const struct object_ops async_ops = +static const struct sync_ops async_sync_ops = { - sizeof(struct async), /* size */ - &no_type, /* type */ - async_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ async_signaled, /* signaled */ async_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops async_ops = +{ + sizeof(struct async), /* size */ + &no_type, /* type */ + async_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -261,7 +265,7 @@ struct async *create_async( struct fd *fd, struct thread *thread, const struct a if (event) release_object( event ); return NULL; } - + async->obj.sync.ops = &async_sync_ops; async->thread = (struct thread *)grab_object( thread ); async->event = event; async->data = *data; @@ -695,11 +699,6 @@ static const struct object_ops iosb_ops = sizeof(struct iosb), /* size */ &no_type, /* type */ iosb_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/atom.c b/server/atom.c index ff0799f5880..04feea060fc 100644 --- a/server/atom.c +++ b/server/atom.c @@ -76,11 +76,6 @@ static const struct object_ops atom_table_ops = sizeof(struct atom_table), /* size */ &no_type, /* type */ atom_table_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/change.c b/server/change.c index f42ce066340..31fa33f2e96 100644 --- a/server/change.c +++ b/server/change.c @@ -109,11 +109,6 @@ static const struct object_ops dir_ops = sizeof(struct dir), /* size */ &file_type, /* type */ dir_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ dir_get_fd, /* get_fd */ default_map_access, /* map_access */ dir_get_sd, /* get_sd */ @@ -1137,10 +1132,8 @@ struct object *create_dir_obj( struct fd *fd, unsigned int access, mode_t mode ) { struct dir *dir;
- dir = alloc_object( &dir_ops ); - if (!dir) - return NULL; - + 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 91f159bc7c9..814d3c8f901 100644 --- a/server/clipboard.c +++ b/server/clipboard.c @@ -73,11 +73,6 @@ static const struct object_ops clipboard_ops = sizeof(struct clipboard), /* size */ &no_type, /* type */ clipboard_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/completion.c b/server/completion.c index 99680ae0680..ad257a57f4d 100644 --- a/server/completion.c +++ b/server/completion.c @@ -84,16 +84,20 @@ static int completion_wait_signaled( struct object *obj, struct wait_queue_entry static void completion_wait_satisfied( struct object *obj, struct wait_queue_entry *entry ); static void completion_wait_destroy( struct object * );
-static const struct object_ops completion_wait_ops = +static const struct sync_ops completion_wait_sync_ops = { - sizeof(struct completion_wait), /* size */ - &no_type, /* type */ - completion_wait_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ completion_wait_signaled, /* signaled */ completion_wait_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops completion_wait_ops = +{ + sizeof(struct completion_wait), /* size */ + &no_type, /* type */ + completion_wait_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -158,16 +162,20 @@ static int completion_signaled( struct object *obj, struct wait_queue_entry *ent static int completion_close_handle( struct object *obj, struct process *process, obj_handle_t handle ); static void completion_destroy( struct object * );
-static const struct object_ops completion_ops = +static const struct sync_ops completion_sync_ops = { - sizeof(struct completion), /* size */ - &completion_type, /* type */ - completion_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ completion_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops completion_ops = +{ + sizeof(struct completion), /* size */ + &completion_type, /* type */ + completion_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -250,6 +258,7 @@ static struct completion_wait *create_completion_wait( struct thread *thread ) struct completion_wait *wait;
if (!(wait = alloc_object( &completion_wait_ops ))) return NULL; + wait->obj.sync.ops = &completion_wait_sync_ops; wait->completion = NULL; wait->thread = thread; wait->msg = NULL; @@ -271,6 +280,7 @@ static struct completion *create_completion( struct object *root, const struct u { if (get_error() != STATUS_OBJECT_NAME_EXISTS) { + completion->obj.sync.ops = &completion_sync_ops; list_init( &completion->queue ); list_init( &completion->wait_queue ); completion->depth = 0; diff --git a/server/console.c b/server/console.c index de6f4e73e31..e0fb85e8cc5 100644 --- a/server/console.c +++ b/server/console.c @@ -76,16 +76,20 @@ static struct object *console_open_file( struct object *obj, unsigned int access unsigned int sharing, unsigned int options ); static int console_add_queue( struct object *obj, struct wait_queue_entry *entry );
-static const struct object_ops console_ops = +static const struct sync_ops console_sync_ops = { - sizeof(struct console), /* size */ - &file_type, /* type */ - console_dump, /* dump */ console_add_queue, /* add_queue */ remove_queue, /* remove_queue */ console_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops console_ops = +{ + sizeof(struct console), /* size */ + &file_type, /* type */ + console_dump, /* dump */ console_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -153,16 +157,20 @@ static struct object *console_server_lookup_name( struct object *obj, struct uni static struct object *console_server_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options );
-static const struct object_ops console_server_ops = +static const struct sync_ops console_server_sync_ops = { - sizeof(struct console_server), /* size */ - &file_type, /* type */ - console_server_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ console_server_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops console_server_ops = +{ + sizeof(struct console_server), /* size */ + &file_type, /* type */ + console_server_dump, /* dump */ console_server_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -222,16 +230,20 @@ static struct fd *screen_buffer_get_fd( struct object *obj ); static struct object *screen_buffer_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options );
-static const struct object_ops screen_buffer_ops = +static const struct sync_ops screen_buffer_sync_ops = { - sizeof(struct screen_buffer), /* size */ - &file_type, /* type */ - screen_buffer_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ screen_buffer_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops screen_buffer_ops = +{ + sizeof(struct screen_buffer), /* size */ + &file_type, /* type */ + screen_buffer_dump, /* dump */ screen_buffer_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -276,11 +288,6 @@ static const struct object_ops console_device_ops = sizeof(struct object), /* size */ &device_type, /* type */ console_device_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -310,16 +317,20 @@ static struct object *console_input_open_file( struct object *obj, unsigned int static struct fd *console_input_get_fd( struct object *obj ); static void console_input_destroy( struct object *obj );
-static const struct object_ops console_input_ops = +static const struct sync_ops console_input_sync_ops = { - sizeof(struct console_input), /* size */ - &device_type, /* type */ - console_input_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ console_input_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops console_input_ops = +{ + sizeof(struct console_input), /* size */ + &device_type, /* type */ + console_input_dump, /* dump */ console_input_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -369,16 +380,20 @@ static struct object *console_output_open_file( struct object *obj, unsigned int unsigned int sharing, unsigned int options ); static void console_output_destroy( struct object *obj );
-static const struct object_ops console_output_ops = +static const struct sync_ops console_output_sync_ops = { - sizeof(struct console_output), /* size */ - &device_type, /* type */ - console_output_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ console_output_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops console_output_ops = +{ + sizeof(struct console_output), /* size */ + &device_type, /* type */ + console_output_dump, /* dump */ console_output_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -432,11 +447,6 @@ static const struct object_ops console_connection_ops = sizeof(struct console_connection),/* size */ &device_type, /* type */ console_connection_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ console_connection_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -535,9 +545,8 @@ static struct object *create_console(void) { struct console *console;
- if (!(console = alloc_object( &console_ops ))) - return NULL; - + if (!(console = alloc_object( &console_ops ))) return NULL; + console->obj.sync.ops = &console_sync_ops; console->renderer = NULL; console->signaled = 0; console->active = NULL; @@ -641,9 +650,8 @@ static struct object *create_screen_buffer( struct console *console ) return NULL; }
- if (!(screen_buffer = alloc_object( &screen_buffer_ops ))) - return NULL; - + if (!(screen_buffer = alloc_object( &screen_buffer_ops ))) return NULL; + screen_buffer->obj.sync.ops = &screen_buffer_sync_ops; screen_buffer->id = ++console->last_id; screen_buffer->input = console; init_async_queue( &screen_buffer->ioctl_q ); @@ -957,6 +965,7 @@ static struct object *create_console_server( void ) struct console_server *server;
if (!(server = alloc_object( &console_server_ops ))) return NULL; + server->obj.sync.ops = &console_server_sync_ops; server->console = NULL; server->busy = 0; server->once_input = 0; @@ -1337,6 +1346,7 @@ static struct object *console_device_lookup_name( struct object *obj, struct uni
name->len = 0; if (!(console_input = alloc_object( &console_input_ops ))) return NULL; + console_input->obj.sync.ops = &console_input_sync_ops; console_input->fd = alloc_pseudo_fd( &console_input_fd_ops, &console_input->obj, FILE_SYNCHRONOUS_IO_NONALERT ); if (!console_input->fd) @@ -1361,6 +1371,7 @@ static struct object *console_device_lookup_name( struct object *obj, struct uni
name->len = 0; if (!(console_output = alloc_object( &console_output_ops ))) return NULL; + console_output->obj.sync.ops = &console_output_sync_ops; console_output->fd = alloc_pseudo_fd( &console_output_fd_ops, &console_output->obj, FILE_SYNCHRONOUS_IO_NONALERT ); if (!console_output->fd) diff --git a/server/debugger.c b/server/debugger.c index 39a740e07e5..09c17712d17 100644 --- a/server/debugger.c +++ b/server/debugger.c @@ -78,16 +78,20 @@ static void debug_event_dump( struct object *obj, int verbose ); static int debug_event_signaled( struct object *obj, struct wait_queue_entry *entry ); static void debug_event_destroy( struct object *obj );
-static const struct object_ops debug_event_ops = +static const struct sync_ops debug_event_sync_ops = { - sizeof(struct debug_event), /* size */ - &no_type, /* type */ - debug_event_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ debug_event_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops debug_event_ops = +{ + sizeof(struct debug_event), /* size */ + &no_type, /* type */ + debug_event_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -106,16 +110,20 @@ static void debug_obj_dump( struct object *obj, int verbose ); static int debug_obj_signaled( struct object *obj, struct wait_queue_entry *entry ); static void debug_obj_destroy( struct object *obj );
-static const struct object_ops debug_obj_ops = +static const struct sync_ops debug_obj_sync_ops = { - sizeof(struct debug_obj), /* size */ - &debug_obj_type, /* type */ - debug_obj_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ debug_obj_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops debug_obj_ops = +{ + sizeof(struct debug_obj), /* size */ + &debug_obj_type, /* type */ + debug_obj_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -359,6 +367,7 @@ static struct debug_obj *create_debug_obj( struct object *root, const struct uni { if (get_error() != STATUS_OBJECT_NAME_EXISTS) { + debug_obj->obj.sync.ops = &debug_obj_sync_ops; debug_obj->flags = flags; list_init( &debug_obj->event_queue ); } @@ -427,6 +436,7 @@ static struct debug_event *alloc_debug_event( struct thread *thread, int code, c
/* build the event */ if (!(event = alloc_object( &debug_event_ops ))) return NULL; + event->obj.sync.ops = &debug_event_sync_ops; event->state = EVENT_QUEUED; event->sender = (struct thread *)grab_object( thread ); event->file = NULL; diff --git a/server/device.c b/server/device.c index 1f93cca437d..13a6728939b 100644 --- a/server/device.c +++ b/server/device.c @@ -63,11 +63,6 @@ static const struct object_ops irp_call_ops = sizeof(struct irp_call), /* size */ &no_type, /* type */ irp_call_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -98,16 +93,20 @@ static void device_manager_dump( struct object *obj, int verbose ); static int device_manager_signaled( struct object *obj, struct wait_queue_entry *entry ); static void device_manager_destroy( struct object *obj );
-static const struct object_ops device_manager_ops = +static const struct sync_ops device_manager_sync_ops = { - sizeof(struct device_manager), /* size */ - &no_type, /* type */ - device_manager_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ device_manager_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops device_manager_ops = +{ + sizeof(struct device_manager), /* size */ + &no_type, /* type */ + device_manager_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -160,11 +159,6 @@ static const struct object_ops device_ops = sizeof(struct device), /* size */ &device_type, /* type */ device_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -212,11 +206,6 @@ static const struct object_ops device_file_ops = sizeof(struct device_file), /* size */ &file_type, /* type */ device_file_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ device_file_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -429,7 +418,7 @@ 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 ); @@ -825,6 +814,7 @@ static struct device_manager *create_device_manager(void)
if ((manager = alloc_object( &device_manager_ops ))) { + manager->obj.sync.ops = &device_manager_sync_ops; manager->current_call = NULL; list_init( &manager->devices ); list_init( &manager->requests ); diff --git a/server/directory.c b/server/directory.c index fd689c561bc..6abd7e5c238 100644 --- a/server/directory.c +++ b/server/directory.c @@ -66,11 +66,6 @@ static const struct object_ops object_type_ops = sizeof(struct object_type), /* size */ &objtype_type, /* type */ object_type_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -116,11 +111,6 @@ static const struct object_ops directory_ops = sizeof(struct directory), /* size */ &directory_type, /* type */ directory_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/event.c b/server/event.c index ad7c09acc99..f9aa2d6244d 100644 --- a/server/event.c +++ b/server/event.c @@ -64,16 +64,20 @@ static void event_satisfied( struct object *obj, struct wait_queue_entry *entry static int event_signal( struct object *obj, unsigned int access); static struct list *event_get_kernel_obj_list( struct object *obj );
-static const struct object_ops event_ops = +static const struct sync_ops event_sync_ops = { - sizeof(struct event), /* size */ - &event_type, /* type */ - event_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ event_signaled, /* signaled */ event_satisfied, /* satisfied */ event_signal, /* signal */ +}; + +static const struct object_ops event_ops = +{ + sizeof(struct event), /* size */ + &event_type, /* type */ + event_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -111,16 +115,20 @@ struct keyed_event static void keyed_event_dump( struct object *obj, int verbose ); static int keyed_event_signaled( struct object *obj, struct wait_queue_entry *entry );
-static const struct object_ops keyed_event_ops = +static const struct sync_ops keyed_event_sync_ops = { - sizeof(struct keyed_event), /* size */ - &keyed_event_type, /* type */ - keyed_event_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ keyed_event_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops keyed_event_ops = +{ + sizeof(struct keyed_event), /* size */ + &keyed_event_type, /* type */ + keyed_event_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -147,6 +155,7 @@ struct event *create_event( struct object *root, const struct unicode_str *name, if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ + event->obj.sync.ops = &event_sync_ops; list_init( &event->kernel_object ); event->manual_reset = manual_reset; event->signaled = initial_state; @@ -233,6 +242,7 @@ struct keyed_event *create_keyed_event( struct object *root, const struct unicod if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ + event->obj.sync.ops = &keyed_event_sync_ops; } } return event; diff --git a/server/fd.c b/server/fd.c index bb0e90d99d0..b9366ee69e0 100644 --- a/server/fd.c +++ b/server/fd.c @@ -157,18 +157,23 @@ 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 void fd_destroy( struct object *obj );
+const struct sync_ops default_fd_sync_ops = +{ + add_queue, /* add_queue */ + remove_queue, /* remove_queue */ + default_fd_signaled, /* signaled */ + no_satisfied, /* satisfied */ + no_signal, /* signal */ +}; + static const struct object_ops fd_ops = { sizeof(struct fd), /* size */ &no_type, /* type */ fd_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -205,11 +210,6 @@ static const struct object_ops device_ops = sizeof(struct device), /* size */ &no_type, /* type */ device_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -245,11 +245,6 @@ static const struct object_ops inode_ops = sizeof(struct inode), /* size */ &no_type, /* type */ inode_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -282,16 +277,20 @@ struct file_lock static void file_lock_dump( struct object *obj, int verbose ); static int file_lock_signaled( struct object *obj, struct wait_queue_entry *entry );
-static const struct object_ops file_lock_ops = +static const struct sync_ops file_lock_sync_ops = { - sizeof(struct file_lock), /* size */ - &no_type, /* type */ - file_lock_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ file_lock_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops file_lock_ops = +{ + sizeof(struct file_lock), /* size */ + &no_type, /* type */ + file_lock_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -1422,6 +1421,7 @@ static struct file_lock *add_lock( struct fd *fd, int shared, file_pos_t start, struct file_lock *lock;
if (!(lock = alloc_object( &file_lock_ops ))) return NULL; + lock->obj.sync.ops = &file_lock_sync_ops; lock->shared = shared; lock->start = start; lock->end = end; @@ -2170,7 +2170,7 @@ int check_fd_events( struct fd *fd, int events ) }
/* default signaled() routine for objects that poll() on an fd */ -int default_fd_signaled( struct object *obj, struct wait_queue_entry *entry ) +static int default_fd_signaled( struct object *obj, struct wait_queue_entry *entry ) { struct fd *fd = get_obj_fd( obj ); int ret = fd->signaled; diff --git a/server/file.c b/server/file.c index 8f6566a0077..666b1a6f55e 100644 --- a/server/file.c +++ b/server/file.c @@ -91,11 +91,6 @@ static const struct object_ops file_ops = sizeof(struct file), /* size */ &file_type, /* type */ file_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ file_get_fd, /* get_fd */ default_map_access, /* map_access */ file_get_sd, /* get_sd */ @@ -145,7 +140,7 @@ 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 ); @@ -173,6 +168,7 @@ 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 ); @@ -188,9 +184,10 @@ struct file *create_file_for_fd_obj( struct fd *fd, unsigned int access, unsigne
static struct object *create_file_obj( struct fd *fd, unsigned int access, mode_t mode ) { - struct file *file = alloc_object( &file_ops ); + struct file *file;
- if (!file) return NULL; + 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 59b73c0245c..66a67ec4a16 100644 --- a/server/file.h +++ b/server/file.h @@ -24,6 +24,7 @@ #include <sys/types.h>
#include "object.h" +#include "thread.h"
struct fd; struct mapping; @@ -108,7 +109,6 @@ 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 int default_fd_signaled( struct object *obj, struct wait_queue_entry *entry ); 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,6 +132,8 @@ 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 8968df73647..39dad955ed2 100644 --- a/server/handle.c +++ b/server/handle.c @@ -123,11 +123,6 @@ static const struct object_ops handle_table_ops = sizeof(struct handle_table), /* size */ &no_type, /* type */ handle_table_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/hook.c b/server/hook.c index ffe7206369e..45e185f9896 100644 --- a/server/hook.c +++ b/server/hook.c @@ -78,11 +78,6 @@ static const struct object_ops hook_table_ops = sizeof(struct hook_table), /* size */ &no_type, /* type */ hook_table_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/mailslot.c b/server/mailslot.c index c54281c2101..3d338b06e71 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -78,11 +78,6 @@ static const struct object_ops mailslot_ops = sizeof(struct mailslot), /* size */ &file_type, /* type */ mailslot_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ mailslot_get_fd, /* get_fd */ mailslot_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -139,11 +134,6 @@ static const struct object_ops mail_writer_ops = sizeof(struct mail_writer), /* size */ &file_type, /* type */ mail_writer_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ mail_writer_get_fd, /* get_fd */ mail_writer_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -204,11 +194,6 @@ static const struct object_ops mailslot_device_ops = sizeof(struct mailslot_device), /* size */ &device_type, /* type */ mailslot_device_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -234,11 +219,6 @@ static const struct object_ops mailslot_device_file_ops = sizeof(struct mailslot_device_file), /* size */ &file_type, /* type */ mailslot_device_file_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ mailslot_device_file_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -483,6 +463,7 @@ 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 ))) { @@ -558,7 +539,7 @@ 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 247b28cf6f5..a755577a77f 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -64,11 +64,6 @@ static const struct object_ops ranges_ops = sizeof(struct ranges), /* size */ &no_type, /* type */ ranges_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -100,11 +95,6 @@ static const struct object_ops shared_map_ops = sizeof(struct shared_map), /* size */ &no_type, /* type */ shared_map_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -173,11 +163,6 @@ static const struct object_ops mapping_ops = sizeof(struct mapping), /* size */ &mapping_type, /* type */ mapping_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ mapping_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/mutex.c b/server/mutex.c index af0efe72132..5b7184e6913 100644 --- a/server/mutex.c +++ b/server/mutex.c @@ -65,16 +65,20 @@ static void mutex_satisfied( struct object *obj, struct wait_queue_entry *entry static void mutex_destroy( struct object *obj ); static int mutex_signal( struct object *obj, unsigned int access );
-static const struct object_ops mutex_ops = +static const struct sync_ops mutex_sync_ops = { - sizeof(struct mutex), /* size */ - &mutex_type, /* type */ - mutex_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ mutex_signaled, /* signaled */ mutex_satisfied, /* satisfied */ mutex_signal, /* signal */ +}; + +static const struct object_ops mutex_ops = +{ + sizeof(struct mutex), /* size */ + &mutex_type, /* type */ + mutex_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -123,6 +127,7 @@ static struct mutex *create_mutex( struct object *root, const struct unicode_str if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ + mutex->obj.sync.ops = &mutex_sync_ops; mutex->count = 0; mutex->owner = NULL; mutex->abandoned = 0; diff --git a/server/named_pipe.c b/server/named_pipe.c index 6e4ae371a1b..a281e908fe6 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -116,11 +116,6 @@ static const struct object_ops named_pipe_ops = sizeof(struct named_pipe), /* size */ &no_type, /* type */ named_pipe_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ named_pipe_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -164,11 +159,6 @@ static const struct object_ops pipe_server_ops = sizeof(struct pipe_server), /* size */ &file_type, /* type */ pipe_server_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ pipe_end_get_fd, /* get_fd */ default_map_access, /* map_access */ pipe_end_get_sd, /* get_sd */ @@ -208,11 +198,6 @@ static const struct object_ops pipe_client_ops = sizeof(struct pipe_end), /* size */ &file_type, /* type */ pipe_client_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ pipe_end_get_fd, /* get_fd */ default_map_access, /* map_access */ pipe_end_get_sd, /* get_sd */ @@ -255,11 +240,6 @@ static const struct object_ops named_pipe_device_ops = sizeof(struct named_pipe_device), /* size */ &device_type, /* type */ named_pipe_device_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -286,11 +266,6 @@ static const struct object_ops named_pipe_device_file_ops = sizeof(struct named_pipe_device_file), /* size */ &file_type, /* type */ named_pipe_device_file_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ named_pipe_device_file_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -336,11 +311,6 @@ static const struct object_ops named_pipe_dir_ops = sizeof(struct named_pipe_device_file), /* size */ &file_type, /* type */ named_pipe_dir_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ named_pipe_dir_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -554,10 +524,10 @@ static struct object *named_pipe_device_lookup_name( struct object *obj, struct if (!name->len && name->str) { /* open the root directory */ - struct named_pipe_device_file *dir = alloc_object( &named_pipe_dir_ops ); - - if (!dir) return NULL; + 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 );
@@ -576,6 +546,7 @@ 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 ))) { @@ -1406,10 +1377,8 @@ static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned { struct pipe_server *server;
- server = alloc_object( &pipe_server_ops ); - if (!server) - return NULL; - + 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; @@ -1432,10 +1401,8 @@ static struct pipe_end *create_pipe_client( struct named_pipe *pipe, data_size_t { struct pipe_end *client;
- client = alloc_object( &pipe_client_ops ); - if (!client) - return NULL; - + 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 cd368ef724a..70f83870bf7 100644 --- a/server/object.c +++ b/server/object.c @@ -105,11 +105,6 @@ static const struct object_ops apc_reserve_ops = sizeof(struct reserve), /* size */ &apc_reserve_type, /* type */ dump_reserve, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -129,11 +124,6 @@ static const struct object_ops completion_reserve_ops = sizeof(struct reserve), /* size */ &completion_reserve_type, /* type */ dump_reserve, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -295,6 +285,15 @@ WCHAR *default_get_full_name( struct object *obj, data_size_t *ret_len ) return (WCHAR *)ret; }
+static const struct sync_ops no_sync_ops = +{ + no_add_queue, /* add_queue */ + NULL, /* remove_queue */ + NULL, /* signaled */ + NULL, /* satisfied */ + no_signal, /* signal */ +}; + /* allocate and initialize an object */ void *alloc_object( const struct object_ops *ops ) { @@ -305,6 +304,7 @@ void *alloc_object( const struct object_ops *ops ) obj->handle_count = 0; obj->is_permanent = 0; obj->ops = ops; + obj->sync.ops = &no_sync_ops; obj->name = NULL; obj->sd = NULL; list_init( &obj->wait_queue ); diff --git a/server/object.h b/server/object.h index 1058f9bfb0a..199ce98ed65 100644 --- a/server/object.h +++ b/server/object.h @@ -63,15 +63,9 @@ struct type_descr unsigned int handle_max; /* max count of handles of this type */ };
-/* operations valid on all objects */ -struct object_ops +/* operations valid on waitable objects */ +struct sync_ops { - /* size of this object type */ - size_t size; - /* type descriptor */ - struct type_descr *type; - /* dump the object (for debugging) */ - void (*dump)(struct object *,int); /* add a thread to the object wait queue */ int (*add_queue)(struct object *,struct wait_queue_entry *); /* remove a thread from the object wait queue */ @@ -82,6 +76,22 @@ struct object_ops void (*satisfied)(struct object *,struct wait_queue_entry *); /* signal an object */ int (*signal)(struct object *, unsigned int); +}; + +struct sync +{ + const struct sync_ops *ops; +}; + +/* operations valid on all objects */ +struct object_ops +{ + /* size of this object type */ + size_t size; + /* type descriptor */ + struct type_descr *type; + /* dump the object (for debugging) */ + 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 *); /* map access rights to the specific rights for this object */ @@ -114,6 +124,7 @@ struct object unsigned int refcount; /* reference count */ unsigned int handle_count;/* handle count */ const struct object_ops *ops; + struct sync sync; struct list wait_queue; struct object_name *name; struct security_descriptor *sd; diff --git a/server/process.c b/server/process.c index b161e3394ba..19ece8c56c4 100644 --- a/server/process.c +++ b/server/process.c @@ -97,16 +97,20 @@ static struct list *process_get_kernel_obj_list( struct object *obj ); static void process_destroy( struct object *obj ); static void terminate_process( struct process *process, struct thread *skip, int exit_code );
-static const struct object_ops process_ops = +static const struct sync_ops process_sync_ops = { - sizeof(struct process), /* size */ - &process_type, /* type */ - process_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ process_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops process_ops = +{ + sizeof(struct process), /* size */ + &process_type, /* type */ + process_dump, /* dump */ no_get_fd, /* get_fd */ process_map_access, /* map_access */ process_get_sd, /* get_sd */ @@ -148,16 +152,20 @@ static void startup_info_dump( struct object *obj, int verbose ); static int startup_info_signaled( struct object *obj, struct wait_queue_entry *entry ); static void startup_info_destroy( struct object *obj );
-static const struct object_ops startup_info_ops = +static const struct sync_ops startup_info_sync_ops = { - sizeof(struct startup_info), /* size */ - &no_type, /* type */ - startup_info_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ startup_info_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops startup_info_ops = +{ + sizeof(struct startup_info), /* size */ + &no_type, /* type */ + startup_info_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -209,16 +217,20 @@ struct job struct list child_job_list; /* list of child jobs */ };
-static const struct object_ops job_ops = +static const struct sync_ops job_sync_ops = { - sizeof(struct job), /* size */ - &job_type, /* type */ - job_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ job_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops job_ops = +{ + sizeof(struct job), /* size */ + &job_type, /* type */ + job_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -243,6 +255,7 @@ static struct job *create_job_object( struct object *root, const struct unicode_ if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ + job->obj.sync.ops = &job_sync_ops; list_init( &job->process_list ); list_init( &job->child_job_list ); job->num_processes = 0; @@ -650,6 +663,7 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla close( fd ); goto error; } + process->obj.sync.ops = &process_sync_ops; process->parent_id = 0; process->debug_obj = NULL; process->debug_event = NULL; @@ -1199,6 +1213,7 @@ DECL_HANDLER(new_process) release_object( parent ); return; } + info->obj.sync.ops = &startup_info_sync_ops; info->process = NULL; info->data = NULL;
diff --git a/server/queue.c b/server/queue.c index b4b6069f927..7146ee51a2c 100644 --- a/server/queue.c +++ b/server/queue.c @@ -157,16 +157,20 @@ static void thread_input_dump( struct object *obj, int verbose ); static void thread_input_destroy( struct object *obj ); static void timer_callback( void *private );
-static const struct object_ops msg_queue_ops = +static const struct sync_ops msg_queue_sync_ops = { - sizeof(struct msg_queue), /* size */ - &no_type, /* type */ - msg_queue_dump, /* dump */ msg_queue_add_queue, /* add_queue */ msg_queue_remove_queue, /* remove_queue */ msg_queue_signaled, /* signaled */ msg_queue_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops msg_queue_ops = +{ + sizeof(struct msg_queue), /* size */ + &no_type, /* type */ + msg_queue_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -199,11 +203,6 @@ static const struct object_ops thread_input_ops = sizeof(struct thread_input), /* size */ &no_type, /* type */ thread_input_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -301,6 +300,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
if ((queue = alloc_object( &msg_queue_ops ))) { + queue->obj.sync.ops = &msg_queue_sync_ops; queue->fd = NULL; queue->paint_count = 0; queue->hotkey_count = 0; diff --git a/server/registry.c b/server/registry.c index c60c737feff..bd80d3e7399 100644 --- a/server/registry.c +++ b/server/registry.c @@ -177,11 +177,6 @@ static const struct object_ops key_ops = sizeof(struct key), /* size */ &key_type, /* type */ key_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ key_map_access, /* map_access */ key_get_sd, /* get_sd */ diff --git a/server/request.c b/server/request.c index 2254315b79e..474750523bf 100644 --- a/server/request.c +++ b/server/request.c @@ -86,11 +86,6 @@ static const struct object_ops master_socket_ops = sizeof(struct master_socket), /* size */ &no_type, /* type */ master_socket_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/semaphore.c b/server/semaphore.c index 53b42a886df..7c7de0f77f7 100644 --- a/server/semaphore.c +++ b/server/semaphore.c @@ -62,16 +62,20 @@ static int semaphore_signaled( struct object *obj, struct wait_queue_entry *entr static void semaphore_satisfied( struct object *obj, struct wait_queue_entry *entry ); static int semaphore_signal( struct object *obj, unsigned int access );
-static const struct object_ops semaphore_ops = +static const struct sync_ops semaphore_sync_ops = { - sizeof(struct semaphore), /* size */ - &semaphore_type, /* type */ - semaphore_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ semaphore_signaled, /* signaled */ semaphore_satisfied, /* satisfied */ semaphore_signal, /* signal */ +}; + +static const struct object_ops semaphore_ops = +{ + sizeof(struct semaphore), /* size */ + &semaphore_type, /* type */ + semaphore_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -103,6 +107,7 @@ static struct semaphore *create_semaphore( struct object *root, const struct uni if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ + sem->obj.sync.ops = &semaphore_sync_ops; sem->count = initial; sem->max = max; } diff --git a/server/serial.c b/server/serial.c index 209f2e9174e..aedc962174a 100644 --- a/server/serial.c +++ b/server/serial.c @@ -88,11 +88,6 @@ static const struct object_ops serial_ops = sizeof(struct serial), /* size */ &file_type, /* type */ serial_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ serial_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -137,7 +132,7 @@ 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 19b76d44c16..8016c507367 100644 --- a/server/signal.c +++ b/server/signal.c @@ -59,11 +59,6 @@ static const struct object_ops handler_ops = sizeof(struct handler), /* size */ &no_type, /* type */ handler_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/sock.c b/server/sock.c index e064f867ff4..4dd973ae7d8 100644 --- a/server/sock.c +++ b/server/sock.c @@ -483,11 +483,6 @@ static const struct object_ops sock_ops = sizeof(struct sock), /* size */ &file_type, /* type */ sock_dump, /* dump */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - default_fd_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ sock_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -1782,6 +1777,7 @@ 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; @@ -3692,11 +3688,6 @@ static const struct object_ops ifchange_ops = sizeof(struct ifchange), /* size */ &no_type, /* type */ ifchange_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ ifchange_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -3913,11 +3904,6 @@ static const struct object_ops socket_device_ops = sizeof(struct object), /* size */ &device_type, /* type */ socket_device_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/symlink.c b/server/symlink.c index 74b60162c01..125130fc90c 100644 --- a/server/symlink.c +++ b/server/symlink.c @@ -68,11 +68,6 @@ static const struct object_ops symlink_ops = sizeof(struct symlink), /* size */ &symlink_type, /* type */ symlink_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/thread.c b/server/thread.c index ffc016bfa56..ea4432ec6a6 100644 --- a/server/thread.c +++ b/server/thread.c @@ -98,16 +98,20 @@ static int thread_apc_signaled( struct object *obj, struct wait_queue_entry *ent static void thread_apc_destroy( struct object *obj ); static void clear_apc_queue( struct list *queue );
-static const struct object_ops thread_apc_ops = +static const struct sync_ops thread_apc_sync_ops = { - sizeof(struct thread_apc), /* size */ - &no_type, /* type */ - dump_thread_apc, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ thread_apc_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops thread_apc_ops = +{ + sizeof(struct thread_apc), /* size */ + &no_type, /* type */ + dump_thread_apc, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -140,16 +144,20 @@ static const unsigned int system_flags = SERVER_CTX_DEBUG_REGISTERS; static void dump_context( struct object *obj, int verbose ); static int context_signaled( struct object *obj, struct wait_queue_entry *entry );
-static const struct object_ops context_ops = +static const struct sync_ops context_sync_ops = { - sizeof(struct context), /* size */ - &no_type, /* type */ - dump_context, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ context_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops context_ops = +{ + sizeof(struct context), /* size */ + &no_type, /* type */ + dump_context, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -189,16 +197,20 @@ static void thread_poll_event( struct fd *fd, int event ); static struct list *thread_get_kernel_obj_list( struct object *obj ); static void destroy_thread( struct object *obj );
-static const struct object_ops thread_ops = +static const struct sync_ops thread_sync_ops = { - sizeof(struct thread), /* size */ - &thread_type, /* type */ - dump_thread, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ thread_signaled, /* signaled */ no_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops thread_ops = +{ + sizeof(struct thread), /* size */ + &thread_type, /* type */ + dump_thread, /* dump */ no_get_fd, /* get_fd */ thread_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -389,6 +401,7 @@ static inline void init_thread_structure( struct thread *thread ) { int i;
+ thread->obj.sync.ops = &thread_sync_ops; thread->unix_pid = -1; /* not known yet */ thread->unix_tid = -1; /* not known yet */ thread->context = NULL; @@ -458,6 +471,7 @@ static struct context *create_thread_context( struct thread *thread ) { struct context *context; if (!(context = alloc_object( &context_ops ))) return NULL; + context->obj.sync.ops = &context_sync_ops; context->status = STATUS_PENDING; memset( &context->regs, 0, sizeof(context->regs) ); context->regs[CTX_NATIVE].machine = native_machine; @@ -683,6 +697,7 @@ static struct thread_apc *create_apc( struct object *owner, const union apc_call
if ((apc = alloc_object( &thread_apc_ops ))) { + apc->obj.sync.ops = &thread_apc_sync_ops; if (call_data) apc->call = *call_data; else apc->call.type = APC_NONE; apc->caller = NULL; @@ -976,18 +991,18 @@ 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->ops->satisfied( entry->obj, entry ); + entry->obj->sync.ops->satisfied( entry->obj, entry ); } else { entry = wait->queues + status; - entry->obj->ops->satisfied( entry->obj, entry ); + entry->obj->sync.ops->satisfied( entry->obj, 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->ops->remove_queue( entry->obj, entry ); + entry->obj->sync.ops->remove_queue( entry->obj, entry ); if (wait->user) remove_timeout_user( wait->user ); free( wait ); return status; @@ -1017,7 +1032,7 @@ static int wait_on( const union select_op *select_op, unsigned int count, struct { struct object *obj = objects[i]; entry->wait = wait; - if (!obj->ops->add_queue( obj, entry )) + if (!obj->sync.ops->add_queue( obj, entry )) { wait->count = i; end_wait( current, get_error() ); @@ -1071,13 +1086,13 @@ 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->ops->signaled( entry->obj, entry ); + not_ok |= !entry->obj->sync.ops->signaled( entry->obj, entry ); if (!not_ok) return STATUS_WAIT_0; } else { for (i = 0, entry = wait->queues; i < wait->count; i++, entry++) - if (entry->obj->ops->signaled( entry->obj, entry )) return i; + if (entry->obj->sync.ops->signaled( entry->obj, entry )) return i; }
if ((wait->flags & SELECT_ALERTABLE) && !list_empty(&thread->user_apc)) return STATUS_USER_APC; @@ -1193,7 +1208,7 @@ static int signal_object( obj_handle_t handle ) obj = get_handle_obj( current->process, handle, 0, NULL ); if (obj) { - ret = obj->ops->signal( obj, get_handle_access( current->process, handle )); + ret = obj->sync.ops->signal( obj, get_handle_access( current->process, handle )); release_object( obj ); } return ret; diff --git a/server/timer.c b/server/timer.c index b0b6ec81535..c82845cf80f 100644 --- a/server/timer.c +++ b/server/timer.c @@ -68,16 +68,20 @@ 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 );
-static const struct object_ops timer_ops = +static const struct sync_ops timer_sync_ops = { - sizeof(struct timer), /* size */ - &timer_type, /* type */ - timer_dump, /* dump */ add_queue, /* add_queue */ remove_queue, /* remove_queue */ timer_signaled, /* signaled */ timer_satisfied, /* satisfied */ no_signal, /* signal */ +}; + +static const struct object_ops timer_ops = +{ + sizeof(struct timer), /* size */ + &timer_type, /* type */ + timer_dump, /* dump */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -104,6 +108,7 @@ static struct timer *create_timer( struct object *root, const struct unicode_str if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ + timer->obj.sync.ops = &timer_sync_ops; timer->manual = manual; timer->signaled = 0; timer->when = 0; diff --git a/server/token.c b/server/token.c index 7e20c670a16..e7a975ae793 100644 --- a/server/token.c +++ b/server/token.c @@ -142,11 +142,6 @@ static const struct object_ops token_ops = sizeof(struct token), /* size */ &token_type, /* type */ token_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/window.c b/server/window.c index f7f9d5e517f..da215ab5b78 100644 --- a/server/window.c +++ b/server/window.c @@ -104,11 +104,6 @@ static const struct object_ops window_ops = sizeof(struct window), /* size */ &no_type, /* type */ window_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ diff --git a/server/winstation.c b/server/winstation.c index b3746090ccf..5b33abb257f 100644 --- a/server/winstation.c +++ b/server/winstation.c @@ -73,11 +73,6 @@ static const struct object_ops winstation_ops = sizeof(struct winstation), /* size */ &winstation_type, /* type */ winstation_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */ @@ -113,11 +108,6 @@ static const struct object_ops desktop_ops = sizeof(struct desktop), /* size */ &desktop_type, /* type */ desktop_dump, /* dump */ - no_add_queue, /* add_queue */ - NULL, /* remove_queue */ - NULL, /* signaled */ - NULL, /* satisfied */ - no_signal, /* signal */ no_get_fd, /* get_fd */ default_map_access, /* map_access */ default_get_sd, /* get_sd */