[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/2] AioContext: avoid leaking deleted BHs on cle
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH v2 1/2] AioContext: avoid leaking deleted BHs on cleanup |
Date: |
Tue, 28 Jul 2015 13:12:55 +0100 |
BHs are freed during aio_bh_poll(). This leads to memory leaks if there
is no aio_bh_poll() between qemu_bh_delete() and aio_ctx_finalize().
Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
async.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/async.c b/async.c
index 9a98a74..929d533 100644
--- a/async.c
+++ b/async.c
@@ -234,7 +234,20 @@ aio_ctx_finalize(GSource *source)
aio_set_event_notifier(ctx, &ctx->notifier, NULL);
event_notifier_cleanup(&ctx->notifier);
rfifolock_destroy(&ctx->lock);
+
+ qemu_mutex_lock(&ctx->bh_lock);
+ while (ctx->first_bh) {
+ QEMUBH *next = ctx->first_bh->next;
+
+ /* TODO ignore leaks for now, change to an assertion in the future */
+ if (ctx->first_bh->deleted) {
+ g_free(ctx->first_bh);
+ }
+ ctx->first_bh = next;
+ }
+ qemu_mutex_unlock(&ctx->bh_lock);
qemu_mutex_destroy(&ctx->bh_lock);
+
timerlistgroup_deinit(&ctx->tlg);
}
--
2.4.3