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