mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
udp: fix torrent count statistics
This commit is contained in:
parent
68e951cf79
commit
ebf4ecbf6a
3 changed files with 25 additions and 13 deletions
|
|
@ -84,6 +84,7 @@ impl TorrentMaps {
|
||||||
self.ipv6.scrape(request)
|
self.ipv6.scrape(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove forbidden or inactive torrents, reclaim space and update statistics
|
/// Remove forbidden or inactive torrents, reclaim space and update statistics
|
||||||
pub fn clean_and_update_statistics(
|
pub fn clean_and_update_statistics(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -105,15 +106,18 @@ impl TorrentMaps {
|
||||||
.clean_and_get_statistics(config, statistics_sender, &mut cache, mode, now);
|
.clean_and_get_statistics(config, statistics_sender, &mut cache, mode, now);
|
||||||
|
|
||||||
if config.statistics.active() {
|
if config.statistics.active() {
|
||||||
statistics.ipv4.peers.store(ipv4.0, Ordering::Relaxed);
|
statistics.ipv4.torrents.store(ipv4.0, Ordering::Relaxed);
|
||||||
statistics.ipv6.peers.store(ipv6.0, Ordering::Relaxed);
|
statistics.ipv6.torrents.store(ipv6.0, Ordering::Relaxed);
|
||||||
|
|
||||||
if let Some(message) = ipv4.1.map(StatisticsMessage::Ipv4PeerHistogram) {
|
statistics.ipv4.peers.store(ipv4.1, Ordering::Relaxed);
|
||||||
|
statistics.ipv6.peers.store(ipv6.1, Ordering::Relaxed);
|
||||||
|
|
||||||
|
if let Some(message) = ipv4.2.map(StatisticsMessage::Ipv4PeerHistogram) {
|
||||||
if let Err(err) = statistics_sender.try_send(message) {
|
if let Err(err) = statistics_sender.try_send(message) {
|
||||||
::log::error!("couldn't send statistics message: {:#}", err);
|
::log::error!("couldn't send statistics message: {:#}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(message) = ipv6.1.map(StatisticsMessage::Ipv6PeerHistogram) {
|
if let Some(message) = ipv6.2.map(StatisticsMessage::Ipv6PeerHistogram) {
|
||||||
if let Err(err) = statistics_sender.try_send(message) {
|
if let Err(err) = statistics_sender.try_send(message) {
|
||||||
::log::error!("couldn't send statistics message: {:#}", err);
|
::log::error!("couldn't send statistics message: {:#}", err);
|
||||||
}
|
}
|
||||||
|
|
@ -204,7 +208,8 @@ impl<I: Ip> TorrentMapShards<I> {
|
||||||
access_list_cache: &mut AccessListCache,
|
access_list_cache: &mut AccessListCache,
|
||||||
access_list_mode: AccessListMode,
|
access_list_mode: AccessListMode,
|
||||||
now: SecondsSinceServerStart,
|
now: SecondsSinceServerStart,
|
||||||
) -> (usize, Option<Histogram<u64>>) {
|
) -> (usize, usize, Option<Histogram<u64>>) {
|
||||||
|
let mut total_num_torrents = 0;
|
||||||
let mut total_num_peers = 0;
|
let mut total_num_peers = 0;
|
||||||
|
|
||||||
let mut opt_histogram: Option<Histogram<u64>> = if config.statistics.torrent_peer_histograms
|
let mut opt_histogram: Option<Histogram<u64>> = if config.statistics.torrent_peer_histograms
|
||||||
|
|
@ -271,8 +276,10 @@ impl<I: Ip> TorrentMapShards<I> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only remove if no peers have been added since previous
|
// Check pending_removal flag set in previous cleaning step. This
|
||||||
// cleaning step
|
// prevents us from removing TorrentData entries that were just
|
||||||
|
// added but do not yet contain any peers. Also double-check that
|
||||||
|
// no peers have been added since we last checked.
|
||||||
if torrent_data
|
if torrent_data
|
||||||
.pending_removal
|
.pending_removal
|
||||||
.fetch_and(false, Ordering::Acquire)
|
.fetch_and(false, Ordering::Acquire)
|
||||||
|
|
@ -285,9 +292,11 @@ impl<I: Ip> TorrentMapShards<I> {
|
||||||
});
|
});
|
||||||
|
|
||||||
torrent_map_shard.shrink_to_fit();
|
torrent_map_shard.shrink_to_fit();
|
||||||
|
|
||||||
|
total_num_torrents += torrent_map_shard.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
(total_num_peers, opt_histogram)
|
(total_num_torrents, total_num_peers, opt_histogram)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_shard(&self, info_hash: &InfoHash) -> &RwLock<TorrentMapShard<I>> {
|
fn get_shard(&self, info_hash: &InfoHash) -> &RwLock<TorrentMapShard<I>> {
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,10 @@ fn print_to_stdout(config: &Config, statistics: &CollectedStatistics) {
|
||||||
" error: {:>10}",
|
" error: {:>10}",
|
||||||
statistics.responses_per_second_error
|
statistics.responses_per_second_error
|
||||||
);
|
);
|
||||||
println!(" torrents: {:>10}", statistics.num_torrents);
|
println!(
|
||||||
|
" torrents: {:>10} (updated every {}s)",
|
||||||
|
statistics.num_torrents, config.cleaning.torrent_cleaning_interval
|
||||||
|
);
|
||||||
println!(
|
println!(
|
||||||
" peers: {:>10} (updated every {}s)",
|
" peers: {:>10} (updated every {}s)",
|
||||||
statistics.num_peers, config.cleaning.torrent_cleaning_interval
|
statistics.num_peers, config.cleaning.torrent_cleaning_interval
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@
|
||||||
<h2>IPv4</h2>
|
<h2>IPv4</h2>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<caption>* Peer count is updated every { peer_update_interval } seconds</caption>
|
<caption>* Torrent/peer count is updated every { peer_update_interval } seconds</caption>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Number of torrents</th>
|
<th scope="row">Number of torrents</th>
|
||||||
<td>{ ipv4.num_torrents }</td>
|
<td>{ ipv4.num_torrents } *</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Number of peers</th>
|
<th scope="row">Number of peers</th>
|
||||||
|
|
@ -141,10 +141,10 @@
|
||||||
<h2>IPv6</h2>
|
<h2>IPv6</h2>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<caption>* Peer count is updated every { peer_update_interval } seconds</caption>
|
<caption>* Torrent/peer count is updated every { peer_update_interval } seconds</caption>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Number of torrents</th>
|
<th scope="row">Number of torrents</th>
|
||||||
<td>{ ipv6.num_torrents }</td>
|
<td>{ ipv6.num_torrents } *</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Number of peers</th>
|
<th scope="row">Number of peers</th>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue