fix(network): SSDP discovery no longer parks a tokio worker for 3s
check_upnp_available uses a blocking std UdpSocket and, on a network
with no UPnP gateway (the normal case right after a node moves), runs
out its full 3s read timeout. Inline on the runtime that blocked a
worker on every call, from four call sites. Same class as the OpenWrt
SSH stall (e282c059), smaller blast radius — move it to spawn_blocking.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
e282c05911
commit
6e89acced7
@@ -97,7 +97,15 @@ async fn get_wan_ip() -> Option<String> {
|
||||
}
|
||||
|
||||
/// Check if UPnP is available by attempting SSDP discovery.
|
||||
///
|
||||
/// The socket is a blocking `std::net::UdpSocket`, and on a network with no
|
||||
/// UPnP gateway — the normal case right after a node moves — the recv runs
|
||||
/// out its full read timeout. Inline on the runtime that parked a tokio
|
||||
/// worker for those 3s on every call, the same failure shape (smaller blast
|
||||
/// radius) as the OpenWrt SSH connect that stalled the API on framework-pt.
|
||||
/// Keep it on the blocking pool.
|
||||
async fn check_upnp_available() -> bool {
|
||||
tokio::task::spawn_blocking(|| {
|
||||
use std::net::UdpSocket;
|
||||
|
||||
let ssdp_request = "M-SEARCH * HTTP/1.1\r\n\
|
||||
@@ -133,6 +141,9 @@ async fn check_upnp_available() -> bool {
|
||||
}
|
||||
Err(_) => false,
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Add a port forward (stored locally; actual UPnP mapping done on request).
|
||||
|
||||
Reference in New Issue
Block a user