diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index d306475b722..98b32648809 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -607,6 +607,13 @@ where let _guard = accept_span.enter(); debug!("got incoming connection"); + + // # Correctness + // + // Holding the drop guard returned by Span::enter across .await points will + // result in incorrect traces if it yields. + // + // This await is okay because the handshaker's `poll_ready` method always returns Ready. handshaker.ready().await?; // TODO: distinguish between proxied listeners and direct listeners let handshaker_span = info_span!("listen_handshaker", peer = ?connected_addr); @@ -638,6 +645,9 @@ where handshakes.push(Box::pin(handshake_task)); } + // We need to drop the guard before yielding. + std::mem::drop(_guard); + // Rate-limit inbound connection handshakes. // But sleep longer after a successful connection, // so we can clear out failed connections at a higher rate.