From e880a89c467abdaa48b50b6ba6d6c1551537263c Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Tue, 1 Oct 2024 20:34:48 +0700 Subject: test add mutex Signed-off-by: fadhil riyanto --- main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.c b/main.c index 03cd88a..3420846 100644 --- a/main.c +++ b/main.c @@ -628,11 +628,19 @@ static void* start_clean_conn_gc(void *srv_ctx_voidptr) if (srv_ctx->th_pool->th_pool[i].need_join == 1 && srv_ctx->th_pool->th_pool[i].is_active == 0) { + usleep(50); + + + + pthread_mutex_lock(&srv_ctx->th_pool->th_pool_mutex); + pthread_join(srv_ctx->th_pool->th_pool[i].th,&ret); srv_ctx->th_pool->th_pool[i].is_active = 0; srv_ctx->th_pool->th_pool[i].need_join = 0; printf("gc clear\n"); + + pthread_mutex_unlock(&srv_ctx->th_pool->th_pool_mutex); } @@ -758,6 +766,10 @@ static void* start_long_poll_receiver(void *srv_ctx_voidptr) EPOLL_ACCEPTFD_WATCHLIST_LEN, 20); + if (n_ready_read < 0) { + perror("epoll_wait"); + } + if (n_ready_read > 0) { for (int i = 0; i < n_ready_read; i++) { -- cgit v1.2.3