--- gvpe/src/vpn.C 2003/04/08 03:25:35 1.10 +++ gvpe/src/vpn.C 2003/04/13 00:42:04 1.12 @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -83,6 +84,8 @@ if (ipv4_fd < 0) return -1; + fcntl (ipv4_fd, F_SETFL, O_NONBLOCK); + #ifdef IP_MTU_DISCOVER // this I really consider a linux bug. I am neither connected // nor do I fragment myself. Linux still sets DF and doesn't @@ -113,6 +116,8 @@ if (udpv4_fd < 0) return -1; + fcntl (udpv4_fd, F_SETFL, O_NONBLOCK); + // standard daemon practise... { int oval = 1; @@ -150,6 +155,8 @@ if (icmpv4_fd < 0) return -1; + fcntl (icmpv4_fd, F_SETFL, O_NONBLOCK); + #ifdef ICMP_FILTER { icmp_filter oval; @@ -193,6 +200,8 @@ if (tcpv4_fd < 0) return -1; + fcntl (tcpv4_fd, F_SETFL, O_NONBLOCK); + // standard daemon practise... { int oval = 1; @@ -625,17 +634,19 @@ connection *vpn::find_router () { - u32 prio = 0; + u32 prio = 1; connection *router = 0; for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) { connection *c = *i; - if (c->conf->routerprio > prio - && c->connectmode == conf_node::C_ALWAYS - && c->conf != THISNODE - && c->ictx && c->octx) + if (c->conf->routerprio >= prio + && c->connectmode == conf_node::C_ALWAYS // so we don't drop the connection if in use + && c->ictx && c->octx + && c->conf != THISNODE // redundant, since ictx==octx==0 always on thisnode + && (!THISNODE->routerprio + || c->conf->routerprio <= THISNODE->routerprio)) { prio = c->conf->routerprio; router = c;