From f90a145d9d29682295aebf2bcd30865ee5f6491f Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Tue, 2 Apr 2024 07:53:54 +0000
Subject: [PATCH 42/69] fix message queue concurrent bug

Signed-off-by: jikai <jikai11@huawei.com>
---
 src/daemon/mailbox/message_queue.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/daemon/mailbox/message_queue.c b/src/daemon/mailbox/message_queue.c
index 7fe044f2..7e53301e 100644
--- a/src/daemon/mailbox/message_queue.c
+++ b/src/daemon/mailbox/message_queue.c
@@ -106,11 +106,12 @@ message_queue *message_queue_create(void (*release)(void *))
         return NULL;
     }
 
-    bq = blocking_queue_create(BLOCKING_QUEUE_NO_TIMEOUT, release);
-    if (bq == NULL) {
+    mq->messages = blocking_queue_create(BLOCKING_QUEUE_NO_TIMEOUT, release);
+    if (mq->messages == NULL) {
         ERROR("Failed to create events queue");
         return NULL;
     }
+    bq = mq->messages;
 
     mq->subscribers = map_new(MAP_PTR_INT, MAP_DEFAULT_CMP_FUNC, message_queue_subscriber_free);
     if (mq->subscribers == NULL) {
@@ -131,7 +132,7 @@ message_queue *message_queue_create(void (*release)(void *))
         return NULL;
     }
 
-    mq->messages = isula_transfer_ptr(bq);
+    bq = NULL;
     return isula_transfer_ptr(mq);
 }
 
-- 
2.34.1

