mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
aquatic: announce handler: improve safety by small margin
This commit is contained in:
parent
789783cfe4
commit
766606cc08
1 changed files with 39 additions and 35 deletions
|
|
@ -84,8 +84,9 @@ pub fn handle_announce_requests(
|
|||
let max_num_peers_to_take = (request.peers_wanted.0.max(0) as usize)
|
||||
.min(config.max_response_peers);
|
||||
|
||||
let torrent_data = state.torrents.get(&request.info_hash).unwrap();
|
||||
|
||||
// Since there is a miniscule risk of the torrent having been removed
|
||||
// by now, don't unwrap the result.
|
||||
if let Some(torrent_data) = state.torrents.get(&request.info_hash){
|
||||
match peer_status {
|
||||
PeerStatus::Leeching => {
|
||||
torrent_data.num_leechers.fetch_add(1, Ordering::SeqCst);
|
||||
|
|
@ -121,6 +122,9 @@ pub fn handle_announce_requests(
|
|||
});
|
||||
|
||||
Some((response, src))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue