Skip to content

Bug: DNS-SD registration doesn't handle the case where an old registration for netremote is already present #293

@abeltrano

Description

@abeltrano

Describe the bug
When a prior invocation of netremote-server exited unexpectedly, the DNS-SD registration may not have been unregistered. In such cases, the next execution of netremote-server will complain that DNS-SD registration failed per below:

Netremote server starting (log level=info)
...
Netremote server started listening on 0.0.0.0:5047
Starting discovery service
Starting systemd-resolved DNS-SD service registration
Failed to register DNS-SD service with systemd-resolved: [org.freedesktop.resolve1.DnssdServiceExists] DNS-SD service 'netremote' exists already
Failed to register new DNS-SD service on dbus

The code ignores this assuming it is fine. In most cases it will be, however, if the new netremote-server execution was bound to a different IP address, then the DNS-SD registration would need to be replaced.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Start netremote-server with no arguments.
  2. Forcibly kill the netremote server process (eg. kill -9 $(pidof netremote-server)).
  3. Start netremote-server with no arguments.

Expected behavior
Any old DNS-SD registration is removed, and replaced with an updated one. No error messages regarding DNS-SD are observed in the log.

Actual behavior
Error messages about failing to register DNS-SD appear, quoting existing registration. DNS-SD registration is not updated.

Screenshots
image

Proposed Fix
ResolvedDnssd::RegisterService should first check if any registration(s) for the supplied serviceName argument exist. If they do, they should be unregistered by calling the ResolvedDnssd::UnregisterService function with the object path of the existing DNS-SD registration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions