From 9f7141b28e2da9db7d7cb099d1f13f28742ff0fa Mon Sep 17 00:00:00 2001 From: Bitflash Date: Thu, 30 Jul 2026 13:38:12 -0300 Subject: rendezvous: bound the wait for a dial, so a dead path is noticed (#51) A node registers at a relay and waits to be dialled. The wait had no bound, and ConnectTo() clears the socket timeout on purpose -- a registration is idle by design and may sit for a long time. What that cannot survive is the path dying with neither end saying so, which is the ordinary case and not the exotic one: a NAT drops the idle mapping, a relay restarts, a route changes. No FIN arrives, nothing becomes readable, and recv() never returns. The thread stays alive and asleep, so ThreadBtfAccept never reaches the `continue` that would register again. The node is unreachable and every outward sign says it is fine. Caught on the bootstrap seed: 27 minutes without a block, eight behind the network, relay reachable the whole time, and a restart fixing it instantly. Nothing in the log marked the moment it went deaf. I tried TCP keepalive first and it does not work here. With probes every 5s and a 2-probe limit, a socket whose replies were being dropped was still ESTAB after four minutes with the probe counter stuck at zero. It is measured, not assumed, and that approach is not in this change. So the bound is ours to enforce, at the one place that knows what waiting means. RvServiceWaitPaired takes a timeout; expiring is not an error but "nobody came, go round again", which the loop above already handles. Cost is one reconnect per relay per five minutes. Verified by killing a registration's path silently -- dropping only the relay's replies, so no RST or FIN is ever seen. With a 60s bound for the test: rendezvous: no dial at 92.246.128.180:8434 within 60s (or it dropped us), re-registering Registrations went 1 -> 2 and the node carried on. Before this, the same treatment left it blocked past four minutes with no log line at all. The socket goes back to blocking once a dial lands, because from that point it is a data tunnel and a tunnel is allowed to sit quiet between messages. --- src/net.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/net.h') diff --git a/src/net.h b/src/net.h index 364fbfb..4379d04 100644 --- a/src/net.h +++ b/src/net.h @@ -43,6 +43,14 @@ static const unsigned int MAX_PEX_DESCRIPTOR_BYTES = 1024; // connection is the intended traffic; anything faster is someone else's idea. static const int64 PEX_MIN_INTERVAL = 60; +// How long to sit registered at a rendezvous relay before giving up on this +// attempt and registering again. Bounded because a registration socket that +// goes quiet is indistinguishable, from inside recv(), from one whose path has +// died -- and the second kind never wakes up. Five minutes is short enough +// that a node is unreachable only briefly and long enough that the reconnect +// traffic is nothing: one per relay per five minutes. +static const int BTF_RENDEZVOUS_WAIT_SECS = 300; + // Descriptors to hand a peer: ours first, then peers that answered us. void BtfPexCollect(std::vector& vDescOut); // Verify descriptors a peer sent and remember the good ones. Returns how many. -- cgit v1.2.3