pex: reduce unnecessary ping traffic
[project/unetd.git] / pex.c
diff --git a/pex.c b/pex.c
index c15982de76d24e32e1cc15eaab56987390671185..78820844632c7799eae21e75acc9ed4c6d588aad 100644 (file)
--- a/pex.c
+++ b/pex.c
@@ -343,8 +343,12 @@ network_pex_query_hosts(struct network *net)
 static void
 network_pex_send_ping(struct network *net, struct network_peer *peer)
 {
+       if (peer->state.pinged || !peer->state.endpoint.sa.sa_family)
+               return;
+
        pex_msg_init(net, PEX_MSG_PING);
        pex_msg_send(net, peer);
+       peer->state.pinged = true;
 }
 
 static void