Skip to content

Commit d82d94b

Browse files
authored
discovery: don't panic on libmdns errors (#1427)
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).
1 parent 755aa2e commit d82d94b

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
on Android platform.
3030
- [core] Fix "Invalid Credentials" when using a Keymaster access token and
3131
client ID on Android platform.
32-
= [connect] Fix "play" command not handled if missing "offset" property
32+
- [connect] Fix "play" command not handled if missing "offset" property
33+
- [discovery] Fix libmdns zerconf setup errors not propagating to the main task.
3334

3435
### Removed
3536

discovery/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,17 @@ fn launch_libmdns(
396396

397397
let task_handle = tokio::task::spawn_blocking(move || {
398398
let inner = move || -> Result<(), DiscoveryError> {
399-
let svc = if !zeroconf_ip.is_empty() {
399+
let responder = if !zeroconf_ip.is_empty() {
400400
libmdns::Responder::spawn_with_ip_list(
401401
&tokio::runtime::Handle::current(),
402402
zeroconf_ip,
403403
)
404404
} else {
405405
libmdns::Responder::spawn(&tokio::runtime::Handle::current())
406406
}
407-
.map_err(|e| DiscoveryError::DnsSdError(Box::new(e)))
408-
.unwrap()
409-
.register(
407+
.map_err(|e| DiscoveryError::DnsSdError(Box::new(e)))?;
408+
409+
let svc = responder.register(
410410
DNS_SD_SERVICE_NAME.to_owned(),
411411
name.into_owned(),
412412
port,

0 commit comments

Comments
 (0)