From a7c66c34a729d67c1cc567e1991afb4b81ce2942 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: Wed, 26 Oct 2022 15:22:31 +0800 Subject: [PATCH] fix busywait in el7 --- server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.c b/server.c index 64536b6..615f23c 100644 --- a/server.c +++ b/server.c @@ -62,7 +62,7 @@ static int kanb_file_ro_cnt, data_file_ro_cnt; #define MAXWAITSEC 16 #define TIMERDATSZ BUFSIZ -static struct timeval timeout = {MAXWAITSEC/4, 0}; +static struct timeval timeout; // accept_timer 使用的结构体 // 包含了本次 accept 的全部信息 @@ -128,6 +128,7 @@ static void accept_client() { FD_COPY(&tmpfds, &rdfds); FD_COPY(&tmpfds, &erfds); puts("Selecting..."); + timeout.tv_sec = MAXWAITSEC/4; int r = select(THREADCNT+8, &rdfds, &wrfds, &erfds, &timeout); if(r < 0) { perror("select");