X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_packet.c;h=d1cbf47d91397ed08f0e87a61131aefac8a99981;hb=fd7e81983ca4cae7cdf2a67a35500284f17761c4;hp=36ad02bcf7b19fbfe05d19184b11be8f96e6d20d;hpb=f91651414adcac1c05e1b923bee4cb3caf559c3b;p=meshlink diff --git a/src/net_packet.c b/src/net_packet.c index 36ad02bc..d1cbf47d 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -279,10 +279,8 @@ static void choose_udp_address(meshlink_handle_t *mesh, const node_t *n, const s to the node's reflexive UDP address discovered during key exchange. */ - static int x = 0; - - if(++x >= 3) { - x = 0; + if(++mesh->udp_choice >= 3) { + mesh->udp_choice = 0; return; } @@ -498,7 +496,6 @@ void broadcast_packet(meshlink_handle_t *mesh, const node_t *from, vpn_packet_t static node_t *try_harder(meshlink_handle_t *mesh, const sockaddr_t *from, const vpn_packet_t *pkt) { node_t *n = NULL; bool hard = false; - static time_t last_hard_try = 0; for splay_each(edge_t, e, mesh->edges) { if(!e->to->status.reachable || e->to == mesh->self) { @@ -506,7 +503,7 @@ static node_t *try_harder(meshlink_handle_t *mesh, const sockaddr_t *from, const } if(sockaddrcmp_noport(from, &e->address)) { - if(last_hard_try == mesh->loop.now.tv_sec) { + if(mesh->last_hard_try == mesh->loop.now.tv_sec) { continue; } @@ -522,10 +519,9 @@ static node_t *try_harder(meshlink_handle_t *mesh, const sockaddr_t *from, const } if(hard) { - last_hard_try = mesh->loop.now.tv_sec; + mesh->last_hard_try = mesh->loop.now.tv_sec; } - last_hard_try = mesh->loop.now.tv_sec; return n; }