Skip to content

Commit 162bb97

Browse files
author
Threepwood-7
committed
RUST-BUG-064: cover all UDP source batch servers
1 parent aad6f15 commit 162bb97

5 files changed

Lines changed: 83 additions & 11 deletions

File tree

crates/emulebb-core/src/ed2k_sources.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ pub(crate) fn configured_server_attempts(config: &Ed2kConfig) -> usize {
9494
.max(1)
9595
}
9696

97+
pub(crate) fn global_udp_source_batch_server_attempts(config: &Ed2kConfig) -> usize {
98+
// WHY: MFC's UDP source walk uses the server list, not the tiny diagnostic
99+
// budget. Batched Rust sends selected packets before waiting for replies.
100+
configured_server_attempts(config)
101+
}
102+
97103
pub(crate) fn exact_ed2k_hash_query_token(query: &str) -> Option<String> {
98104
let trimmed = query.trim();
99105
let candidate = trimmed

crates/emulebb-core/src/ed2k_sources/tests.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
use std::net::Ipv4Addr;
22

3+
use emulebb_ed2k::config::Ed2kConfig;
34
use emulebb_kad_dht::SourceResult;
45
use emulebb_kad_proto::Ed2kHash;
56

6-
use super::kad_source_result_to_ed2k_found_source;
7+
use super::{
8+
configured_server_attempts, global_udp_source_batch_server_attempts,
9+
kad_source_result_to_ed2k_found_source,
10+
};
711

812
fn kad_source(udp_port: u16) -> SourceResult {
913
SourceResult {
@@ -32,3 +36,22 @@ fn kad_high_id_source_preserves_nonzero_source_udp_port() {
3236
None
3337
);
3438
}
39+
40+
#[test]
41+
fn global_udp_source_batch_attempts_cover_effective_server_list() {
42+
let mut config = Ed2kConfig {
43+
source_server_attempt_budget: 1,
44+
server_endpoints: vec![
45+
"192.0.2.10:4661".to_string(),
46+
"192.0.2.20:4661".to_string(),
47+
"192.0.2.30:4661".to_string(),
48+
],
49+
..Ed2kConfig::default()
50+
};
51+
52+
assert_eq!(configured_server_attempts(&config), 3);
53+
assert_eq!(global_udp_source_batch_server_attempts(&config), 3);
54+
55+
config.server_endpoints.clear();
56+
assert_eq!(global_udp_source_batch_server_attempts(&config), 1);
57+
}

crates/emulebb-core/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ use ed2k_sources::{
123123
Ed2kServerCallbackRoute, LearnedEd2kMetadata, OwnSourceIdentity, collect_kad_ed2k_metadata,
124124
collect_kad_ed2k_sources, configured_server_attempts, direct_download_candidate_sources,
125125
drop_self_sources, ed2k_server_callback_route, found_source_from_hint,
126-
global_udp_source_search_excluded_endpoint, hash_only_ed2k_search_query,
127-
kad_source_result_to_ed2k_found_source, keyword_target, manifest_has_ed2k_transfer_progress,
128-
merge_download_sources, new_direct_ed2k_source_count, plaintext_fallback_for_obfuscated_source,
129-
select_ed2k_keyword_metadata, should_adopt_hash_only_metadata_name,
130-
should_query_kad_source_supplement, should_query_server_udp_source_supplement,
131-
should_refresh_ed2k_server_sources, should_skip_no_progress_source_requery,
132-
sort_download_sources, source_endpoint_key, source_key,
126+
global_udp_source_batch_server_attempts, global_udp_source_search_excluded_endpoint,
127+
hash_only_ed2k_search_query, kad_source_result_to_ed2k_found_source, keyword_target,
128+
manifest_has_ed2k_transfer_progress, merge_download_sources, new_direct_ed2k_source_count,
129+
plaintext_fallback_for_obfuscated_source, select_ed2k_keyword_metadata,
130+
should_adopt_hash_only_metadata_name, should_query_kad_source_supplement,
131+
should_query_server_udp_source_supplement, should_refresh_ed2k_server_sources,
132+
should_skip_no_progress_source_requery, sort_download_sources, source_endpoint_key, source_key,
133133
};
134134
#[cfg(test)]
135135
use ed2k_sources::{
@@ -3398,8 +3398,6 @@ impl EmulebbCore {
33983398
) -> Result<Vec<Ed2kFoundSource>> {
33993399
let cancel = CancellationToken::new();
34003400
let config = self.effective_ed2k_config(&network.config, None).await?;
3401-
let attempts =
3402-
configured_server_attempts(&config).min(config.source_server_attempt_budget.max(1));
34033401
let mut sources = Vec::new();
34043402
let (preferred_endpoint, background_search) =
34053403
if let Some(handle) = self.connected_ed2k_search_handle().await {
@@ -3454,7 +3452,7 @@ impl EmulebbCore {
34543452
has_background_search,
34553453
preferred_endpoint,
34563454
),
3457-
max_attempts: attempts,
3455+
max_attempts: global_udp_source_batch_server_attempts(&config),
34583456
targets: &claimed_batch.targets,
34593457
timeout: Duration::from_secs(config.connect_timeout_secs.max(15)),
34603458
cancel: &cancel,

docs/active/INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ items.
7575
| [RUST-BUG-061](items/RUST-BUG-061.md) | Major | DONE | Supplement scarce connected-server sources with global UDP source search |
7676
| [RUST-BUG-062](items/RUST-BUG-062.md) | Major | DONE | Batch ED2K global UDP source requests like MFC |
7777
| [RUST-BUG-063](items/RUST-BUG-063.md) | Major | DONE | Do not serialize ED2K UDP source-batch sends behind per-server waits |
78+
| [RUST-BUG-064](items/RUST-BUG-064.md) | Major | IN_PROGRESS | Cover all effective servers in ED2K UDP source batches |
7879

7980
## Refactors (`REF`)
8081

docs/active/items/RUST-BUG-064.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
id: RUST-BUG-064
3+
title: Cover all effective servers in ED2K UDP source batches
4+
status: in_progress
5+
priority: Major
6+
category: bug
7+
workflow: local
8+
---
9+
10+
# RUST-BUG-064: Cover all effective servers in ED2K UDP source batches
11+
12+
## Problem
13+
14+
Rust's batched ED2K global UDP source search still capped the selected server
15+
walk with `source_server_attempt_budget`, whose default is intentionally tiny
16+
for legacy diagnostic one-shot source probes.
17+
18+
eMuleBB MFC keeps rotating through the global server list for its UDP source
19+
walk. After `RUST-BUG-063`, Rust sends selected batched server packets before
20+
waiting for replies, so covering the effective runtime/imported server list no
21+
longer serializes source acquisition behind one timeout per server.
22+
23+
## Acceptance
24+
25+
- [x] Batched global ED2K UDP source search uses the full effective configured
26+
and runtime-imported server count.
27+
- [x] Legacy source-server attempt budgets remain available to diagnostic
28+
one-shot source paths.
29+
- [x] Focused unit coverage proves a small diagnostic budget does not shrink
30+
the batched global source walk.
31+
- [ ] Live hide.me diagnostics show batched `OP_GLOBGETSOURCES*` packets cover
32+
more than the old three-server cap when more candidate servers are
33+
available.
34+
35+
## Implementation Notes
36+
37+
- Keep the change scoped to active transfer source batching.
38+
- Do not change the default diagnostic source-server attempt budget globally.
39+
40+
## Evidence
41+
42+
- `cargo test -p emulebb-core global_udp_source_batch_attempts_cover_effective_server_list --locked`
43+
- `python tools\check_rust_client_policy.py`
44+
- `python tools\rust_quality_gate.py quick`

0 commit comments

Comments
 (0)