Code cleanup
This commit is contained in:
17
src/main.c
17
src/main.c
@@ -51,6 +51,8 @@
|
|||||||
#define MPTCP_ENABLED (26)
|
#define MPTCP_ENABLED (26)
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
volatile sig_atomic_t quit;
|
||||||
|
volatile sig_atomic_t info;
|
||||||
long timeout;
|
long timeout;
|
||||||
int mptcp;
|
int mptcp;
|
||||||
int state_fd;
|
int state_fd;
|
||||||
@@ -71,9 +73,6 @@ struct crypto_ctx {
|
|||||||
int chacha;
|
int chacha;
|
||||||
};
|
};
|
||||||
|
|
||||||
volatile sig_atomic_t gt_close = 0;
|
|
||||||
volatile sig_atomic_t gt_info = 0;
|
|
||||||
|
|
||||||
_pure_
|
_pure_
|
||||||
static int64_t dt_ms (struct timeval *ta, struct timeval *tb)
|
static int64_t dt_ms (struct timeval *ta, struct timeval *tb)
|
||||||
{
|
{
|
||||||
@@ -366,10 +365,10 @@ static void gt_sa_handler (int sig)
|
|||||||
case SIGINT:
|
case SIGINT:
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
gt_close = 1;
|
gt.quit = 1;
|
||||||
break;
|
break;
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
gt_info = 1;
|
gt.info = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1287,7 +1286,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
state_send(gt.state_fd, "INITIALIZED", tun_name);
|
state_send(gt.state_fd, "INITIALIZED", tun_name);
|
||||||
|
|
||||||
while (!gt_close) {
|
while (!gt.quit) {
|
||||||
if (retry_count>=0 && retry>=retry_count+1) {
|
if (retry_count>=0 && retry>=retry_count+1) {
|
||||||
gt_log("couldn't %s (%d attempt%s)\n", listener?"listen":"connect",
|
gt_log("couldn't %s (%d attempt%s)\n", listener?"listen":"connect",
|
||||||
(int)retry, (retry>1)?"s":"");
|
(int)retry, (retry>1)?"s":"");
|
||||||
@@ -1364,7 +1363,7 @@ int main (int argc, char **argv)
|
|||||||
buffer_format(&sock.read);
|
buffer_format(&sock.read);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if _0_(gt_close)
|
if _0_(gt.quit)
|
||||||
stop_loop |= 1;
|
stop_loop |= 1;
|
||||||
|
|
||||||
if _0_(stop_loop) {
|
if _0_(stop_loop) {
|
||||||
@@ -1418,7 +1417,7 @@ int main (int argc, char **argv)
|
|||||||
const ssize_t r = tun_read(tun.fd, tun.read.write, GT_MTU_MAX);
|
const ssize_t r = tun_read(tun.fd, tun.read.write, GT_MTU_MAX);
|
||||||
|
|
||||||
if (r<=0) {
|
if (r<=0) {
|
||||||
gt_close |= !r;
|
gt.quit |= !r;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1514,7 +1513,7 @@ int main (int argc, char **argv)
|
|||||||
if (r==ic.size)
|
if (r==ic.size)
|
||||||
tun.write.read += r;
|
tun.write.read += r;
|
||||||
} else {
|
} else {
|
||||||
gt_close |= !r;
|
gt.quit |= !r;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user