[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 7/9] colo-compare: safe finalization
From: |
Maxim Davydov |
Subject: |
[PATCH v1 7/9] colo-compare: safe finalization |
Date: |
Tue, 29 Mar 2022 00:15:37 +0300 |
Fixes some possible issues with finalization. For example, finalization
immediately after instance_init fails on the assert.
Signed-off-by: Maxim Davydov <maxim.davydov@openvz.org>
---
net/colo-compare.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 62554b5b3c..81d8de0aaa 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -1426,7 +1426,7 @@ static void colo_compare_finalize(Object *obj)
break;
}
}
- if (QTAILQ_EMPTY(&net_compares)) {
+ if (QTAILQ_EMPTY(&net_compares) && colo_compare_active) {
colo_compare_active = false;
qemu_mutex_destroy(&event_mtx);
qemu_cond_destroy(&event_complete_cond);
@@ -1442,19 +1442,26 @@ static void colo_compare_finalize(Object *obj)
colo_compare_timer_del(s);
- qemu_bh_delete(s->event_bh);
+ if (s->event_bh) {
+ qemu_bh_delete(s->event_bh);
+ }
- AioContext *ctx = iothread_get_aio_context(s->iothread);
- aio_context_acquire(ctx);
- AIO_WAIT_WHILE(ctx, !s->out_sendco.done);
- if (s->notify_dev) {
- AIO_WAIT_WHILE(ctx, !s->notify_sendco.done);
+ if (s->iothread) {
+ AioContext *ctx = iothread_get_aio_context(s->iothread);
+ aio_context_acquire(ctx);
+ AIO_WAIT_WHILE(ctx, !s->out_sendco.done);
+ if (s->notify_dev) {
+ AIO_WAIT_WHILE(ctx, !s->notify_sendco.done);
+ }
+ aio_context_release(ctx);
}
- aio_context_release(ctx);
/* Release all unhandled packets after compare thead exited */
g_queue_foreach(&s->conn_list, colo_flush_packets, s);
- AIO_WAIT_WHILE(NULL, !s->out_sendco.done);
+ /* Without colo_compare_complete done == false without packets */
+ if (!g_queue_is_empty(&s->out_sendco.send_list)) {
+ AIO_WAIT_WHILE(NULL, !s->out_sendco.done);
+ }
g_queue_clear(&s->conn_list);
g_queue_clear(&s->out_sendco.send_list);
--
2.31.1
- Re: [PATCH v1 3/9] mem: appropriate handling getting mem region, (continued)
- [PATCH v1 2/9] pci: add null-pointer check, Maxim Davydov, 2022/03/28
- [PATCH v1 4/9] msmouse: add appropriate unregister handler, Maxim Davydov, 2022/03/28
- [PATCH v1 5/9] wctablet: add appropriate unregister handler, Maxim Davydov, 2022/03/28
- [PATCH v1 6/9] chardev: add appropriate getting address, Maxim Davydov, 2022/03/28
- [PATCH v1 7/9] colo-compare: safe finalization,
Maxim Davydov <=
- [PATCH v1 8/9] qom: add command to print initial properties, Maxim Davydov, 2022/03/28
- [PATCH v1 9/9] scripts: printing machine type compat properties, Maxim Davydov, 2022/03/28
- Re: [PATCH v1 0/9] Machine type compatible properties, Igor Mammedov, 2022/03/31