Merge pull request #91 from greatest-ape/work-2022-09-18_2

udp: fix num_seeders/num_leechers counting error, remove some casts; improve shell scripts
This commit is contained in:
Joakim Frostegård 2022-09-18 18:22:47 +02:00 committed by GitHub
commit 3dcf53e0eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 15 deletions

View file

@ -136,11 +136,11 @@ fn handle_announce_request<I: Ip>(
peer_ip: I,
peer_valid_until: ValidUntil,
) -> AnnounceResponse<I> {
let max_num_peers_to_take = if request.peers_wanted.0 <= 0 {
config.protocol.max_response_peers as usize
let max_num_peers_to_take: usize = if request.peers_wanted.0 <= 0 {
config.protocol.max_response_peers
} else {
::std::cmp::min(
config.protocol.max_response_peers as usize,
config.protocol.max_response_peers,
request.peers_wanted.0.try_into().unwrap(),
)
};
@ -163,8 +163,8 @@ fn handle_announce_request<I: Ip>(
AnnounceResponse {
transaction_id: request.transaction_id,
announce_interval: AnnounceInterval(config.protocol.peer_announce_interval),
leechers: NumberOfPeers(torrent_data.num_leechers() as i32),
seeders: NumberOfPeers(torrent_data.num_seeders() as i32),
leechers: NumberOfPeers(torrent_data.num_leechers().try_into().unwrap_or(i32::MAX)),
seeders: NumberOfPeers(torrent_data.num_seeders().try_into().unwrap_or(i32::MAX)),
peers: response_peers,
}
}

View file

@ -83,10 +83,10 @@ impl<I: Ip> TorrentData<I> {
match opt_removed_peer.map(|peer| peer.is_seeder) {
Some(true) => {
self.num_leechers -= 1;
self.num_seeders -= 1;
}
Some(false) => {
self.num_seeders -= 1;
self.num_leechers -= 1;
}
None => {}
}

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --release --bin aquatic_udp_bench -- $@
cargo run --release -p aquatic_udp_bench -- $@

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --profile "release-debug" --bin aquatic_http_private -- $@
cargo run --profile "release-debug" -p aquatic_http_private -- $@

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --profile "release-debug" --bin aquatic_http -- $@
cargo run --profile "release-debug" -p aquatic_http -- $@

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --profile "release-debug" --bin aquatic_udp -- $@
cargo run --profile "release-debug" -p aquatic_udp -- $@

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --profile "release-debug" --bin aquatic_ws -- $@
cargo run --profile "release-debug" -p aquatic_ws -- $@

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --profile "release-debug" --bin aquatic_http_load_test -- $@
cargo run --profile "release-debug" -p aquatic_http_load_test -- $@

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --profile "release-debug" --bin aquatic_udp_load_test -- $@
cargo run --profile "release-debug" -p aquatic_udp_load_test -- $@

View file

@ -2,4 +2,4 @@
. ./scripts/env-native-cpu-without-avx-512
cargo run --profile "release-debug" --bin aquatic_ws_load_test -- $@
cargo run --profile "release-debug" -p aquatic_ws_load_test -- $@