Module: wine Branch: master Commit: 9c29cee63843cf68ebb99d10b2464bd737127bbf URL: https://source.winehq.org/git/wine.git/?a=commit;h=9c29cee63843cf68ebb99d10b...
Author: Sebastian Lackner sebastian@fds-team.de Date: Tue Jan 26 22:41:43 2021 -0600
server: Store and notify all notification events associated with a given registry handle.
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/tests/reg.c | 6 +++--- server/registry.c | 41 ++++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c index a619bc45cb8..ac1dec9f2f8 100644 --- a/dlls/ntdll/tests/reg.c +++ b/dlls/ntdll/tests/reg.c @@ -1887,7 +1887,7 @@ static void test_notify(void) pRtlFreeUnicodeString(&str);
status = pNtWaitForSingleObject(events[0], FALSE, &timeout); - todo_wine ok(!status, "got %#x\n", status); + ok(!status, "got %#x\n", status); status = pNtWaitForSingleObject(events[1], FALSE, &timeout); ok(!status, "got %#x\n", status); status = pNtWaitForSingleObject(events[2], FALSE, &timeout); @@ -1917,7 +1917,7 @@ static void test_notify(void) ok(status == STATUS_SUCCESS, "NtDeleteSubkey failed: %x\n", status);
status = pNtWaitForSingleObject(events[0], FALSE, &timeout); - todo_wine ok(!status, "got %#x\n", status); + ok(!status, "got %#x\n", status); status = pNtWaitForSingleObject(events[1], FALSE, &timeout); ok(!status, "got %#x\n", status); status = pNtWaitForSingleObject(events[2], FALSE, &timeout); @@ -1935,7 +1935,7 @@ static void test_notify(void) pNtClose(key);
status = pNtWaitForSingleObject(events[0], FALSE, &timeout); - todo_wine ok(!status, "got %#x\n", status); + ok(!status, "got %#x\n", status); status = pNtWaitForSingleObject(events[1], FALSE, &timeout); ok(!status, "got %#x\n", status); status = pNtWaitForSingleObject(events[2], FALSE, &timeout); diff --git a/server/registry.c b/server/registry.c index c937e051597..64aec1d83c9 100644 --- a/server/registry.c +++ b/server/registry.c @@ -52,7 +52,8 @@ struct notify { struct list entry; /* entry in list of notifications */ - struct event *event; /* event to set when changing this key */ + struct event **events; /* events to set when changing this key */ + unsigned int event_count; /* number of events */ int subtree; /* true if subtree notification */ unsigned int filter; /* which events to notify on */ obj_handle_t hkey; /* hkey associated with this notification */ @@ -314,12 +315,17 @@ static struct object_type *key_get_type( struct object *obj ) /* notify waiter and maybe delete the notification */ static void do_notification( struct key *key, struct notify *notify, int del ) { - if (notify->event) + unsigned int i; + + for (i = 0; i < notify->event_count; ++i) { - set_event( notify->event ); - release_object( notify->event ); - notify->event = NULL; + set_event( notify->events[i] ); + release_object( notify->events[i] ); } + free( notify->events ); + notify->events = NULL; + notify->event_count = 0; + if (del) { list_remove( ¬ify->entry ); @@ -2283,20 +2289,13 @@ DECL_HANDLER(set_registry_notification) if (event) { notify = find_notify( key, current->process, req->hkey ); - if (notify) - { - if (notify->event) - release_object( notify->event ); - grab_object( event ); - notify->event = event; - } - else + if (!notify) { notify = mem_alloc( sizeof(*notify) ); if (notify) { - grab_object( event ); - notify->event = event; + notify->events = NULL; + notify->event_count = 0; notify->subtree = req->subtree; notify->filter = req->filter; notify->hkey = req->hkey; @@ -2306,8 +2305,16 @@ DECL_HANDLER(set_registry_notification) } if (notify) { - reset_event( event ); - set_error( STATUS_PENDING ); + struct event **new_array; + + if ((new_array = realloc( notify->events, (notify->event_count + 1) * sizeof(*notify->events) ))) + { + notify->events = new_array; + notify->events[notify->event_count++] = (struct event *)grab_object( event ); + reset_event( event ); + set_error( STATUS_PENDING ); + } + else set_error( STATUS_NO_MEMORY ); } release_object( event ); }