Skip to content

Commit

Permalink
Fix magnet links
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatson committed May 17, 2024
1 parent b687a18 commit f63e729
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion crates/librqbit/src/dht_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Context;
use buffers::ByteBufOwned;
use futures::{stream::FuturesUnordered, Stream, StreamExt};
use librqbit_core::torrent_metainfo::TorrentMetaV1Info;
use tracing::debug;
use tracing::{debug, error_span, Instrument};

use crate::{
peer_connection::PeerConnectionOptions, peer_info_reader, spawn_utils::BlockingSpawner,
Expand Down Expand Up @@ -46,6 +46,7 @@ pub async fn read_metainfo_from_peer_receiver<A: Stream<Item = SocketAddr> + Unp
peer_connection_options,
BlockingSpawner::new(true),
)
.instrument(error_span!("read_metainfo_from_peer", ?addr))
.await
.with_context(|| format!("error reading metainfo from {addr}"));
drop(token);
Expand Down
16 changes: 11 additions & 5 deletions crates/librqbit/src/peer_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use peer_binary_protocol::{
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use tokio::time::timeout;
use tracing::trace;
use tracing::{debug, trace};

use crate::{read_buf::ReadBuf, spawn_utils::BlockingSpawner};

Expand Down Expand Up @@ -262,18 +262,24 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {
trace!("sent bitfield");
}

let mut broadcast_closed = false;

loop {
let req = loop {
break tokio::select! {
r = have_broadcast.recv() => match r {
r = have_broadcast.recv(), if !broadcast_closed => match r {
Ok(id) => {
if self.handler.should_transmit_have(id) {
WriterRequest::Message(MessageOwned::Have(id.get()))
} else {
continue
}
},
Err(tokio::sync::broadcast::error::RecvError::Closed) => anyhow::bail!("closing writer, broadcast channel closed"),
Err(tokio::sync::broadcast::error::RecvError::Closed) => {
broadcast_closed = true;
debug!("broadcast channel closed, will not poll it anymore");
continue
},
_ => continue
},
r = timeout(keep_alive_interval, outgoing_chan.recv()) => match r {
Expand Down Expand Up @@ -389,11 +395,11 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {

tokio::select! {
r = reader => {
trace!("reader is done, exiting");
trace!(result=?r, "reader is done, exiting");
r
}
r = writer => {
trace!("writer is done, exiting");
trace!(result=?r, "writer is done, exiting");
r
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/librqbit/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ impl tracker_comms::TorrentStatsProvider for PeerRxTorrentInfo {
let mt = match mt {
Some(mt) => mt,
None => {
warn!(info_hash=?self.info_hash, "can't find torrent in the session");
trace!(info_hash=?self.info_hash, "can't find torrent in the session, using default stats");
return Default::default();
}
};
Expand Down

0 comments on commit f63e729

Please sign in to comment.