From 5e0e03a0eb346970d50c7dab9be8d37df8f0fc83 Mon Sep 17 00:00:00 2001 From: arya2 Date: Mon, 12 Jun 2023 17:07:58 -0400 Subject: [PATCH] Restores `accept_span` and uses in_scope() instead of enter() --- zebra-network/src/peer_set/initialize.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index 76eb68cbe11..686eab5bfac 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -603,9 +603,17 @@ where ); let connected_addr = peer::ConnectedAddr::new_inbound_direct(addr); - info!(peer = ?connected_addr, "listen_accept"); + let accept_span = info_span!("listen_accept", peer = ?connected_addr); + 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 the executor 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); @@ -637,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.