SpecialProxy/timeout.c

24 lines
498 B
C
Raw Permalink Normal View History

2018-12-07 09:29:41 +08:00
#include "main.h"
#include "http.h"
2019-01-26 11:53:32 +08:00
int timeout_minute;
2018-12-07 09:29:41 +08:00
void *close_timeout_connectionLoop(void *nullPtr)
{
2018-12-21 19:13:07 +08:00
int i;
2018-12-07 09:29:41 +08:00
while (1)
{
2019-01-26 11:53:32 +08:00
sleep(60);
2018-12-07 09:29:41 +08:00
for (i = 0; i < MAX_CONNECTION; i += 2)
2019-01-26 11:53:32 +08:00
if (cts[i].fd > -1)
{
2022-04-04 20:00:36 +08:00
if (cts[i].timer >= timeout_minute) {
printf("关闭连接\n");
2019-01-26 11:53:32 +08:00
close_connection(cts + i);
2022-04-04 20:00:36 +08:00
}
2019-01-26 11:53:32 +08:00
else
2019-02-19 12:27:43 +08:00
cts[i].timer++;
2019-01-26 11:53:32 +08:00
}
2018-12-07 09:29:41 +08:00
}
}