From a077f7b5a94670f5798d6cdac4c122aa4739e689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 27 Oct 2022 19:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96busy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.c b/server.c index dc44551..d9d18ef 100644 --- a/server.c +++ b/server.c @@ -796,19 +796,25 @@ static void handle_accept(void *p) { #endif } CONV_END: puts("Conversation end"); + if(timer_pointer_of(p)->accept_fd) { close(timer_pointer_of(p)->accept_fd); timer_pointer_of(p)->accept_fd = 0; puts("Close accept"); } + close_dict(timer_pointer_of(p)->index); setdicts[timer_pointer_of(p)->index].data[0] = 0; + + pthread_mutex_lock(&timer_pointer_of(p)->mc); + pthread_rwlock_wrlock(&timer_pointer_of(p)->mb); timer_pointer_of(p)->isbusy = 0; - pthread_mutex_lock(&timer_pointer_of(p)->mc); pthread_rwlock_unlock(&timer_pointer_of(p)->mb); + puts("Set thread status to idle"); pthread_cond_wait(&timer_pointer_of(p)->c, &timer_pointer_of(p)->mc); + pthread_mutex_unlock(&timer_pointer_of(p)->mc); puts("Thread wakeup"); }