From 0872e79f0213caae8a492e6a709f1e4e01aa37d4 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: Mon, 24 Oct 2022 22:55:36 +0800 Subject: [PATCH] timer noquit --- server.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/server.c b/server.c index 4fea0ec..f45fc55 100644 --- a/server.c +++ b/server.c @@ -590,6 +590,7 @@ static void accept_timer(void *p) { uint8_t isbusy = timer->isbusy; pthread_rwlock_unlock(&timer->mb); if(!isbusy) { + TIMER_SLEEP: pthread_mutex_lock(&timer->tmc); timer->hastimerslept = 1; puts("Timer sleep"); @@ -608,17 +609,10 @@ static void accept_timer(void *p) { pthread_kill(thread, SIGQUIT); puts("Kill thread"); } - break; + goto TIMER_SLEEP; } sleep(MAXWAITSEC / 4); } - pthread_cond_destroy(&timer->tc); - printf("Destroy timer cond, "); - pthread_mutex_destroy(&timer->tmc); - printf("Destroy timer mutex, "); - timer->timerthread = NULL; - timer->hastimerslept = 0; - puts("Clear timer thread"); } static void cleanup_thread(thread_timer_t* timer) { @@ -649,8 +643,6 @@ static void cleanup_thread(thread_timer_t* timer) { static void process_defer() { for(int i = 0; i < THREADCNT; i++) { if(timers[i].thread) pthread_kill(timers[i].thread, SIGQUIT); - pthread_cond_destroy(&timers[i].tc); - pthread_mutex_destroy(&timers[i].tmc); if(timers[i].timerthread) pthread_kill(timers[i].timerthread, SIGQUIT); } fflush(stdout);