diff mbox series

[3/3] plugins: Iterate on cb_lists in qemu_plugin_user_exit

Message ID 20230117035701.168514-4-richard.henderson@linaro.org
State New
Headers show
Series tests: Fix some deadlocks | expand

Commit Message

Richard Henderson Jan. 17, 2023, 3:57 a.m. UTC
Rather than iterate over all plugins for all events,
iterate over plugins that have registered a given event.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 plugins/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Alex Bennée Jan. 20, 2023, 5:39 p.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> Rather than iterate over all plugins for all events,
> iterate over plugins that have registered a given event.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Queued to plugins/next, thanks.
diff mbox series

Patch

diff --git a/plugins/core.c b/plugins/core.c
index 35aca0266d..f22f8edc74 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -509,9 +509,10 @@  void qemu_plugin_user_exit(void)
     /* un-register all callbacks except the final AT_EXIT one */
     for (ev = 0; ev < QEMU_PLUGIN_EV_MAX; ev++) {
         if (ev != QEMU_PLUGIN_EV_ATEXIT) {
-            struct qemu_plugin_ctx *ctx;
-            QTAILQ_FOREACH(ctx, &plugin.ctxs, entry) {
-                plugin_unregister_cb__locked(ctx, ev);
+            struct qemu_plugin_cb *cb, *next;
+
+            QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) {
+                plugin_unregister_cb__locked(cb->ctx, ev);
             }
         }
     }