From 54c6d63f05fe57461a7cb957c65382a6cce5d12d 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: Sat, 15 Oct 2022 14:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20timer=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.c b/server.c index 054062f..021a078 100644 --- a/server.c +++ b/server.c @@ -46,7 +46,7 @@ struct thread_timer_t { pthread_cond_t tc; pthread_mutex_t tmc; uint8_t isbusy; - uint8_t buf[CMDPACKET_LEN_MAX]; + uint8_t buf[BUFSIZ-sizeof(uint32_t)-sizeof(int)-sizeof(time_t)-sizeof(ssize_t)-sizeof(char*)-2*sizeof(pthread_t)-2*sizeof(pthread_cond_t)-2*sizeof(pthread_mutex_t)-sizeof(pthread_rwlock_t)-sizeof(uint8_t)]; }; typedef struct thread_timer_t thread_timer_t; static thread_timer_t timers[THREADCNT]; @@ -598,6 +598,7 @@ static void accept_timer(void *p) { pthread_cond_wait(&timer->tc, &timer->tmc); pthread_mutex_unlock(&timer->tmc); puts("Timer wake up"); + sleep(MAXWAITSEC / 4); } if(is_dict_opening) touch_timer(p); time_t waitsec = time(NULL) - timer->touch;