mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-14 06:13:09 +00:00
nfqws2: optimize quit logic
This commit is contained in:
@@ -42,6 +42,7 @@ typedef struct _SOCKET_ADDRESS {
|
||||
#include "params.h"
|
||||
#include "gzip.h"
|
||||
#include "helpers.h"
|
||||
#include "nfqws.h"
|
||||
#include "conntrack.h"
|
||||
#include "crypto/sha.h"
|
||||
#include "crypto/aes-gcm.h"
|
||||
@@ -3783,7 +3784,7 @@ static void lua_perror(lua_State *L)
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
static int lua_panic (lua_State *L)
|
||||
static int lua_panic(lua_State *L)
|
||||
{
|
||||
lua_perror(L);
|
||||
DLOG_ERR("LUA PANIC: THIS IS FATAL. DYING.\n");
|
||||
@@ -3952,6 +3953,7 @@ static bool lua_init_scripts(void)
|
||||
|
||||
LIST_FOREACH(str, ¶ms.lua_init_scripts, next)
|
||||
{
|
||||
if (bQuit) return false;
|
||||
if (params.debug)
|
||||
{
|
||||
if (str->str[0]=='@')
|
||||
|
||||
24
nfq2/nfqws.c
24
nfq2/nfqws.c
@@ -458,8 +458,14 @@ static int nfq_main(void)
|
||||
fd = nfq_fd(h);
|
||||
do
|
||||
{
|
||||
if (bQuit) goto quit;
|
||||
while ((rd = recv(fd, buf, RECONSTRUCT_MAX_SIZE, 0)) >= 0)
|
||||
{
|
||||
if (!rd)
|
||||
{
|
||||
DLOG_ERR("recv from nfq returned 0 !\n");
|
||||
goto err;
|
||||
}
|
||||
ReloadCheck();
|
||||
lua_do_gc();
|
||||
#ifdef HAS_FILTER_SSID
|
||||
@@ -467,28 +473,16 @@ static int nfq_main(void)
|
||||
if (!wlan_info_get_rate_limited())
|
||||
DLOG_ERR("cannot get wlan info\n");
|
||||
#endif
|
||||
if (rd)
|
||||
{
|
||||
int r = nfq_handle_packet(h, (char *)buf, (int)rd);
|
||||
if (r) DLOG_ERR("nfq_handle_packet error %d\n", r);
|
||||
}
|
||||
else
|
||||
{
|
||||
DLOG_ERR("recv from nfq returned 0 !\n");
|
||||
goto err;
|
||||
}
|
||||
int r = nfq_handle_packet(h, (char *)buf, (int)rd);
|
||||
if (r) DLOG_ERR("nfq_handle_packet error %d\n", r);
|
||||
if (bQuit) goto quit;
|
||||
}
|
||||
if (errno==EINTR)
|
||||
{
|
||||
if (bQuit) goto quit;
|
||||
continue;
|
||||
}
|
||||
e = errno;
|
||||
DLOG_ERR("recv: recv=%zd errno %d\n", rd, e);
|
||||
errno = e;
|
||||
DLOG_PERROR("recv");
|
||||
if (bQuit) goto quit;
|
||||
// do not fail on ENOBUFS
|
||||
} while (e == ENOBUFS);
|
||||
|
||||
@@ -2117,10 +2111,10 @@ int main(int argc, char **argv)
|
||||
|
||||
srandom(time(NULL));
|
||||
aes_init_keygen_tables(); // required for aes
|
||||
mask_from_bitcount6_prepare();
|
||||
set_env_exedir(argv[0]);
|
||||
set_console_io_buffering();
|
||||
#ifdef __CYGWIN__
|
||||
mask_from_bitcount6_prepare();
|
||||
memset(hash_wf,0,sizeof(hash_wf));
|
||||
prepare_low_appdata();
|
||||
#endif
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
#define HAS_FILTER_SSID 1
|
||||
#endif
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
extern volatile sig_atomic_t bQuit;
|
||||
#endif
|
||||
int main(int argc, char *argv[]);
|
||||
|
||||
// when something changes that can break LUA compatibility this version should be increased
|
||||
|
||||
Reference in New Issue
Block a user