Compare commits

..

8 Commits

Author SHA1 Message Date
angt
babe14d544 Quit on tun error 2016-04-25 10:24:42 +00:00
angt
278fc69789 Update mud 2016-04-21 15:35:35 +00:00
angt
99262777fc Update mud 2016-04-17 10:16:13 +00:00
angt
b0f60caab2 Update mud 2016-04-14 20:12:45 +00:00
angt
efd5e0bb36 Remove down-timeout and use timeout for send-timeout 2016-04-08 14:38:07 +00:00
angt
ade4617d53 Update mud 2016-04-08 13:00:52 +00:00
angt
64a5fd8227 Update mud 2016-04-05 14:23:45 +00:00
angt
eba968797c Add {down,send,pong}-timeout and time-tolerance option 2016-04-05 14:17:07 +00:00
2 changed files with 34 additions and 16 deletions

2
mud

Submodule mud updated: 104bc68266...04c8495fe6

View File

@@ -242,17 +242,20 @@ int main (int argc, char **argv)
gt.timeout = 5000; gt.timeout = 5000;
long time_tolerance = 0;
struct option opts[] = { struct option opts[] = {
{ "host", &host, option_str }, { "host", &host, option_str },
{ "port", &port, option_str }, { "port", &port, option_str },
{ "bind", &bind_list, option_str }, { "bind", &bind_list, option_str },
{ "bind-port", &bind_port, option_str }, { "bind-port", &bind_port, option_str },
{ "dev", &dev, option_str }, { "dev", &dev, option_str },
{ "keyfile", &keyfile, option_str }, { "keyfile", &keyfile, option_str },
{ "multiqueue", NULL, option_option }, { "multiqueue", NULL, option_option },
{ "statefile", &statefile, option_str }, { "statefile", &statefile, option_str },
{ "timeout", &gt.timeout, option_long }, { "timeout", &gt.timeout, option_long },
{ "version", NULL, option_option }, { "time-tolerance", &time_tolerance, option_long },
{ "version", NULL, option_option },
{ NULL }, { NULL },
}; };
@@ -305,6 +308,11 @@ int main (int argc, char **argv)
mud_set_key(mud, gt.key, sizeof(gt.key)); mud_set_key(mud, gt.key, sizeof(gt.key));
mud_set_send_timeout_msec(mud, gt.timeout);
if (time_tolerance > 0)
mud_set_time_tolerance_sec(mud, time_tolerance);
if (bind_list) { if (bind_list) {
char tmp[1024]; char tmp[1024];
char *name = &tmp[0]; char *name = &tmp[0];
@@ -350,9 +358,12 @@ int main (int argc, char **argv)
} }
struct timeval timeout = { struct timeval timeout = {
.tv_usec = 1000, .tv_usec = 100000,
}; };
if (mud_can_push(mud))
timeout.tv_usec = 1000;
if _0_(select(mud_fd+1, &rfds, NULL, NULL, &timeout)==-1) { if _0_(select(mud_fd+1, &rfds, NULL, NULL, &timeout)==-1) {
if (errno==EINTR) if (errno==EINTR)
continue; continue;
@@ -376,8 +387,10 @@ int main (int argc, char **argv)
while (1) { while (1) {
const ssize_t r = tun_read(tun_fd, buf, sizeof(buf)); const ssize_t r = tun_read(tun_fd, buf, sizeof(buf));
if (r<=0) if (r<=0) {
gt.quit |= !r;
break; break;
}
struct ip_common ic; struct ip_common ic;
@@ -392,12 +405,17 @@ int main (int argc, char **argv)
mud_pull(mud); mud_pull(mud);
while (1) { while (1) {
const int r = mud_recv(mud, buf, sizeof(buf)); const int size = mud_recv(mud, buf, sizeof(buf));
if (r<=0) if (size<=0)
break; break;
tun_write(tun_fd, buf, r); const ssize_t r = tun_write(tun_fd, buf, size);
if (r<=0) {
gt.quit |= !r;
break;
}
} }
} }