Skip to content

Commit

Permalink
discovery: don't panic on libmdns errors
Browse files Browse the repository at this point in the history
On panic, the discovery task crashes, but the main program is not
notified of this. Returning an error will result in the Discovery stream
yielding None, serving as notification to the application (which might
shutdown with error, for example, if no other means of authentication is
available).
  • Loading branch information
wisp3rwind committed Dec 19, 2024
1 parent 755aa2e commit 3662325
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,17 @@ fn launch_libmdns(

let task_handle = tokio::task::spawn_blocking(move || {
let inner = move || -> Result<(), DiscoveryError> {
let svc = if !zeroconf_ip.is_empty() {
let responder = if !zeroconf_ip.is_empty() {
libmdns::Responder::spawn_with_ip_list(
&tokio::runtime::Handle::current(),
zeroconf_ip,
)
} else {
libmdns::Responder::spawn(&tokio::runtime::Handle::current())
}
.map_err(|e| DiscoveryError::DnsSdError(Box::new(e)))
.unwrap()
.register(
.map_err(|e| DiscoveryError::DnsSdError(Box::new(e)))?;

let svc = responder.register(
DNS_SD_SERVICE_NAME.to_owned(),
name.into_owned(),
port,
Expand Down

0 comments on commit 3662325

Please sign in to comment.