mirror of
https://github.com/bol-van/zapret2.git
synced 2026-06-17 12:50:04 +04:00
nfqws2: do not call timer code if there're no timers
This commit is contained in:
+15
-1
@@ -524,6 +524,8 @@ static int nfq_main(void)
|
||||
{
|
||||
if (bQuit) goto quit;
|
||||
for(;;)
|
||||
{
|
||||
if (params.timers)
|
||||
{
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(fd, &fdset);
|
||||
@@ -535,6 +537,12 @@ static int nfq_main(void)
|
||||
DLOG_PERROR("select");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bQuit) goto quit;
|
||||
res = 1;
|
||||
}
|
||||
lua_do_gc();
|
||||
ReloadCheck();
|
||||
if (res)
|
||||
@@ -555,6 +563,8 @@ static int nfq_main(void)
|
||||
if (res<0) DLOG_ERR("nfq_handle_packet result %d, errno %d : %s\n", res, errno, strerror(errno));
|
||||
}
|
||||
|
||||
if (params.timers)
|
||||
{
|
||||
bt = boottime_ms();
|
||||
dbt = bt-bt_prev;
|
||||
if (dbt>=params.timer_res)
|
||||
@@ -572,6 +582,7 @@ static int nfq_main(void)
|
||||
tv.tv_usec = (suseconds_t)(dbt%1000*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errno==EINTR)
|
||||
continue;
|
||||
e = errno;
|
||||
@@ -712,7 +723,7 @@ static int dvt_main(void)
|
||||
}
|
||||
FD_ZERO(&fdset);
|
||||
for (i = 0; i < fdct; i++) FD_SET(fd[i], &fdset);
|
||||
r = select(fdmax, &fdset, NULL, NULL, &tv);
|
||||
r = select(fdmax, &fdset, NULL, NULL, params.timers ? &tv : NULL);
|
||||
if (bQuit)
|
||||
{
|
||||
DLOG_CONDUP("quit requested\n");
|
||||
@@ -796,6 +807,8 @@ static int dvt_main(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.timers)
|
||||
{
|
||||
bt = boottime_ms();
|
||||
dbt = bt-bt_prev;
|
||||
if (dbt>=params.timer_res)
|
||||
@@ -813,6 +826,7 @@ static int dvt_main(void)
|
||||
tv.tv_usec = (suseconds_t)(dbt%1000*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exitok:
|
||||
res = 0;
|
||||
|
||||
Reference in New Issue
Block a user