diff --git a/portalnet/src/overlay_service.rs b/portalnet/src/overlay_service.rs index 123721da1..aba56d358 100644 --- a/portalnet/src/overlay_service.rs +++ b/portalnet/src/overlay_service.rs @@ -1281,22 +1281,6 @@ where ) })?; - // Attempt to get semaphore permit if fails we return an empty accept - let permit = match self - .utp_controller - .inbound_utp_transfer_semaphore - .clone() - .try_acquire_owned() - { - Ok(permit) => permit, - Err(_) => { - return Ok(Accept { - connection_id: 0, - content_keys: requested_keys, - }); - } - }; - let content_keys: Vec = request .content_keys .into_iter() @@ -1341,6 +1325,22 @@ where }); } + // Attempt to get semaphore permit, if this fails we return an empty accept + let permit = match self + .utp_controller + .inbound_utp_transfer_semaphore + .clone() + .try_acquire_owned() + { + Ok(permit) => permit, + Err(_) => { + return Ok(Accept { + connection_id: 0, + content_keys: requested_keys, + }); + } + }; + // Generate a connection ID for the uTP connection if there is data we would like to // accept. let node_addr = self.discovery.cached_node_addr(source).ok_or_else(|| { @@ -1417,7 +1417,7 @@ where { debug!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), content_keys = ?content_keys_string, "unable to process uTP payload"); } - // explictically drop semaphore permit in thread so the permit is moved into the thread + // explicitly drop semaphore permit in thread so the permit is moved into the thread drop(permit); });