Repository navigation
feat: report detailed state in DaemonStatus::Running - #524
Merged
Merged
Conversation
Part of #514. The multicast sockets are only set up once, when the daemon starts, and their failures were only logged at debug level. A daemon that could bind neither socket still started, and `status()` said `Running`. - `ServiceDaemon::new()` / `new_with_port()` now create both sockets before spawning the daemon thread, and return an error if neither can be bound. - `DaemonStatus::Running` now carries a `RunningState`, whose `ipv4()` and `ipv6()` tell whether that socket is bound (`is_bound()`) and, if not, why (`bind_error()`). A host without IPv6 still runs on IPv4 alone. - Fix the `new()` / `new_with_port()` docs, which said such failures are reported through `monitor()`. BREAKING CHANGE: `DaemonStatus::Running` is now `DaemonStatus::Running(RunningState)`. Match it with `DaemonStatus::Running(_)`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gState `RunningState` now also lists the interfaces the daemon selected, with the multicast membership of each IP version on them: joined, or the error from the last failed attempt, or none if there is no address of that version. A failed join records nothing in `my_intfs`, so failures are kept in a separate `join_failures` map. An entry is cleared when a later join on that interface and IP version succeeds, when the address is disabled or invalid, or when the IP check no longer finds it. Also: - `Ipv4State` and `Ipv6State` are merged into one public `SocketState`, returned by `ipv4_socket()` / `ipv6_socket()`. - The sockets are registered with the poller in `new()`, which now fails if that does, instead of the daemon thread exiting with only a debug log. - The status is built on request, so the stored `status` field is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With IP checks disabled, a failed join is only retried when the interface selection changes, not at a periodic check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Match the public vocabulary of `enable_interface()` / `disable_interface()`: `SelectedIntf` becomes `EnabledIntf`, and `RunningState::selected_intfs()` becomes `enabled_intfs()`. The public docs no longer mention interface "selection", which is internal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
keepsimple1
added a commit
to WillBux/mdns-sd
that referenced
this pull request
Nov 22, 2026
…hed-addr Pass the address snapshot to the new del_interface_addr() call in test_running_state_reports_join_per_ip_version, added on main by keepsimple1#524.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #514.
Also address issue #544.
Problem
The multicast sockets are set up only once, when the daemon starts, and failures were only logged at
debug!. A daemon that couldn't bind sockets (neither IPv4 or IPv6) still started,register()returnedOk, andstatus()saidRunning. Such failures can't be reported as aDaemonEventeither, since no monitor exists that early. Failed multicast joins on an interface were likewise only logged.Changes
new()fails when nothing can work.ServiceDaemon::new()/new_with_port()now create both sockets and register them with the poller before spawning the daemon thread. They return an error if neither the IPv4 nor the IPv6 socket can be bound, or if registering with the poller fails (previously the daemon thread just exited with a debug log). If only one socket fails (e.g. a host without IPv6), the daemon still runs.DaemonStatus::Running(RunningState).RunningStateis a snapshot of the daemon's local setup, as of when it handled thestatus()request. It does not say whether packets get delivered or whether services can be found.ipv4_socket()/ipv6_socket()return aSocketState, with:is_bound(): whether that multicast socket was bound;bind_error(): why it failed, if it did, so callers can tell "no IPv6 here" from "port in use".enabled_intfs()returns the enabled interfaces the daemon uses, ordered by index, asEnabledIntf:name(),index(), andipv4()/ipv6(), each anOption<Membership>(Noneif the daemon has no address of that version there).Membershiphas:addrs(): the addresses of that version on the interface;is_joined()/join_error(): whether the multicast join worked, or the error from the last failed attempt, which is retried at the next IP check.All four public types are
#[non_exhaustive]with private fields, so more state can be added later without breaking anyone.Join failures are tracked. A failed join records nothing in
my_intfs(since fix: do not record an interface address whose multicast join failed #523), so failures are kept in a separate map. An entry is cleared when a later join on that interface and IP version succeeds, when the address is disabled or invalid, or when the IP check no longer finds it. The status is now built on request, so the storedstatusfield is gone.Docs.
new()/new_with_port()said an unusable port is reported throughmonitor(), which was never the case. They now describe the new behavior, andstatus()says its result is a snapshot.Breaking change
DaemonStatus::Runningis nowDaemonStatus::Running(RunningState). Code matching or comparing it needsDaemonStatus::Running(_). That's a compile error rather than a silent behavior change, but it needs a minor version bump (0.22).