mirror of
https://github.com/ratspeak/rsReticulum
synced 2026-11-22 23:10:33 +00:00
transport: answer a local client's request for a known path from the table
This commit is contained in:
1 parent
559525c3a4
commit
3aaff26b22
2 files changed
+41
-2
No files matched your search
@@ -725,7 +725,10 @@ impl TransportActor {
|
||||
|
||||
// Transport.py: a request for a destination already
|
||||
// in flight joins the waiting requesters instead of being processed.
|
||||
if self.inflight_path_requests.contains_key(&requested_dest) {
|
||||
// A local client's request for a live path is answered from the table.
|
||||
let answer_from_table =
|
||||
is_from_local_client && self.path_table.get_live(&requested_dest).is_some();
|
||||
if !answer_from_table && self.inflight_path_requests.contains_key(&requested_dest) {
|
||||
// A leaf answers batched requesters only for its local clients;
|
||||
// upstream would also emit PATH_RESPONSEs naming the leaf as relay.
|
||||
if (self.is_transport_enabled || is_from_local_client) && !ingress_limited {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! The path-request in-flight gate (Transport.py `inflight_path_requests`):
|
||||
//! a request that leaves nothing pending releases it.
|
||||
//! a request that leaves nothing pending releases it, and a local client's
|
||||
//! request for a live path is answered from the table instead of batched.
|
||||
use super::*;
|
||||
use rns_wire::header::PacketHeader;
|
||||
|
||||
@@ -161,3 +162,38 @@ fn an_unreadable_cached_announce_releases_the_gate() {
|
||||
assert!(!actor.discovery_path_requests.contains_key(&dest));
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
|
||||
/// Transport.py batches every request for an in-flight destination
|
||||
/// (:2244-2259@1.6.1), so a local client waited for a new announce although
|
||||
/// the shared instance held the path. The gate is held here by a network
|
||||
/// request that a leaf only forwards to its local clients (:4166-4177), or
|
||||
/// one a relay has deferred behind an ingress burst.
|
||||
#[test]
|
||||
fn a_local_client_is_answered_from_the_table_behind_a_network_request() {
|
||||
for transport in [false, true] {
|
||||
let mut actor = relay();
|
||||
actor.is_transport_enabled = transport;
|
||||
let mut client = network(&mut actor, 1, InterfaceMode::Full);
|
||||
actor.interfaces.get_mut(&1).unwrap().role = InterfaceRole::LocalClient;
|
||||
let _network = network(&mut actor, 2, InterfaceMode::Full);
|
||||
let (dest, _) = known_path(&mut actor, &format!("local_client_{transport}"), |_| {});
|
||||
if transport {
|
||||
actor.interfaces.get_mut(&2).unwrap().ingress =
|
||||
crate::ingress::IngressController::new();
|
||||
prime_ingress_pr_burst(&mut actor, 2);
|
||||
}
|
||||
request(&mut actor, dest, 1, 2);
|
||||
assert_eq!(
|
||||
requested(&mut client, dest),
|
||||
!transport,
|
||||
"a leaf forwards it to local clients"
|
||||
);
|
||||
assert!(actor.inflight_path_requests.contains_key(&dest));
|
||||
|
||||
request(&mut actor, dest, 2, 1);
|
||||
actor.flush_pending_announces();
|
||||
assert!(answered(&mut client, dest), "transport={transport}");
|
||||
assert!(!actor.inflight_path_requests.contains_key(&dest));
|
||||
let _ = std::fs::remove_dir_all(actor.storage_dir.clone().unwrap());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user