gazelle/0049-post-thread_phase1-sem-to-avoid-block-main-thread-wh.patch

40 lines
1.3 KiB
Diff
Raw Normal View History

From e0d26480fc3919affe10b55ccbb5837aa88c5c57 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 16 May 2022 18:34:55 +0800
Subject: [PATCH 10/18] post thread_phase1 sem to avoid block main thread when
stack error
---
src/lstack/core/lstack_protocol_stack.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index eb975c0..88513ba 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -339,11 +339,13 @@ static struct protocol_stack * stack_thread_init(uint16_t queue_id)
struct protocol_stack *stack = malloc(sizeof(*stack));
if (stack == NULL) {
+ sem_post(&stack_group->thread_phase1);
LSTACK_LOG(ERR, LSTACK, "malloc stack failed\n");
return NULL;
}
if (init_stack_value(stack, queue_id) != 0) {
+ sem_post(&stack_group->thread_phase1);
free(stack);
return NULL;
}
@@ -356,6 +358,7 @@ static struct protocol_stack * stack_thread_init(uint16_t queue_id)
if (use_ltran()) {
if (client_reg_thrd_ring() != 0) {
+ sem_post(&stack_group->thread_phase1);
free(stack);
return NULL;
}
--
2.23.0