96 lines
3.5 KiB
Diff
96 lines
3.5 KiB
Diff
From 1431fd828005acb2aa7df1844cdec62e21f50769 Mon Sep 17 00:00:00 2001
|
|
From: yangchen <yangchen145@huawei.com>
|
|
Date: Wed, 5 Jun 2024 12:56:52 +0800
|
|
Subject: [PATCH] fix MySQL shutdown cmd
|
|
|
|
---
|
|
src/lstack/api/lstack_epoll.c | 14 ++++++--------
|
|
src/lstack/include/posix/lstack_epoll.h | 4 ++--
|
|
2 files changed, 8 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
|
|
index c8a2e43..1d6ae52 100644
|
|
--- a/src/lstack/api/lstack_epoll.c
|
|
+++ b/src/lstack/api/lstack_epoll.c
|
|
@@ -144,7 +144,7 @@ void wakeup_stack_epoll(struct protocol_stack *stack)
|
|
if (__atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) {
|
|
__atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE);
|
|
rte_mb();
|
|
- pthread_mutex_unlock(&wakeup->wait);
|
|
+ sem_post(&wakeup->wait);
|
|
stack->stats.wakeup_events++;
|
|
}
|
|
|
|
@@ -258,12 +258,11 @@ int32_t lstack_do_epoll_create(int32_t fd)
|
|
init_list_node_null(&wakeup->wakeup_list[i]);
|
|
}
|
|
|
|
- if (pthread_mutex_init(&wakeup->wait, NULL) != 0) {
|
|
+ if (sem_init(&wakeup->wait, 0, 0) != 0) {
|
|
posix_api->close_fn(fd);
|
|
free(wakeup);
|
|
GAZELLE_RETURN(EINVAL);
|
|
}
|
|
- pthread_mutex_trylock(&wakeup->wait);
|
|
__atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE);
|
|
|
|
struct protocol_stack_group *stack_group = get_protocol_stack_group();
|
|
@@ -337,7 +336,7 @@ int32_t lstack_epoll_close(int32_t fd)
|
|
list_del_node_null(&wakeup->poll_list);
|
|
pthread_spin_unlock(&stack_group->poll_list_lock);
|
|
|
|
- pthread_mutex_destroy(&wakeup->wait);
|
|
+ sem_destroy(&wakeup->wait);
|
|
|
|
free(wakeup);
|
|
sock->wakeup = NULL;
|
|
@@ -609,9 +608,9 @@ int32_t lstack_block_wait(struct wakeup_poll *wakeup, int32_t timeout)
|
|
if (timeout > 0) {
|
|
struct timespec timespec;
|
|
ms_to_timespec(×pec, timeout);
|
|
- ret = pthread_mutex_timedlock(&wakeup->wait, ×pec);
|
|
+ ret = sem_timedwait(&wakeup->wait, ×pec);
|
|
} else {
|
|
- ret = pthread_mutex_lock(&wakeup->wait);
|
|
+ ret = sem_wait(&wakeup->wait);
|
|
}
|
|
|
|
if (__atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) {
|
|
@@ -714,10 +713,9 @@ int32_t lstack_rtw_epoll_wait(int32_t epfd, struct epoll_event* events, int32_t
|
|
|
|
static int32_t init_poll_wakeup_data(struct wakeup_poll *wakeup)
|
|
{
|
|
- if (pthread_mutex_init(&wakeup->wait, NULL) != 0) {
|
|
+ if (sem_init(&wakeup->wait, 0, 0) != 0) {
|
|
GAZELLE_RETURN(EINVAL);
|
|
}
|
|
- pthread_mutex_trylock(&wakeup->wait);
|
|
__atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE);
|
|
|
|
for (uint32_t i = 0; i < PROTOCOL_STACK_MAX; i++) {
|
|
diff --git a/src/lstack/include/posix/lstack_epoll.h b/src/lstack/include/posix/lstack_epoll.h
|
|
index 59b5ef7..a7164f4 100644
|
|
--- a/src/lstack/include/posix/lstack_epoll.h
|
|
+++ b/src/lstack/include/posix/lstack_epoll.h
|
|
@@ -37,7 +37,7 @@ struct protocol_stack;
|
|
struct wakeup_poll {
|
|
/* stack thread read frequently */
|
|
enum wakeup_type type;
|
|
- pthread_mutex_t wait __rte_cache_aligned;
|
|
+ sem_t wait;
|
|
bool in_wait;
|
|
struct list_node wakeup_list[PROTOCOL_STACK_MAX];
|
|
bool have_kernel_event;
|
|
@@ -87,7 +87,7 @@ static inline void lstack_block_wakeup(struct wakeup_poll *wakeup)
|
|
if (wakeup && __atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) {
|
|
__atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE);
|
|
rte_mb();
|
|
- pthread_mutex_unlock(&wakeup->wait);
|
|
+ sem_post(&wakeup->wait);
|
|
}
|
|
}
|
|
|
|
--
|
|
2.33.0
|
|
|