From 4a142480047f5b814373afc585993a00c135a2c7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 17 Jan 2024 18:51:47 +0100 Subject: [PATCH] lib/avahi/Publisher: move code to RegisterServices(AvahiEntryGroup) --- src/lib/avahi/Publisher.cxx | 18 ++++++++++++------ src/lib/avahi/Publisher.hxx | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/lib/avahi/Publisher.cxx b/src/lib/avahi/Publisher.cxx index d64973e20..97851faf3 100644 --- a/src/lib/avahi/Publisher.cxx +++ b/src/lib/avahi/Publisher.cxx @@ -83,7 +83,7 @@ try { } /* And recreate the services */ - RegisterServices(avahi_entry_group_get_client(g)); + RegisterServices(*g); break; case AVAHI_ENTRY_GROUP_FAILURE: @@ -129,6 +129,16 @@ AddServices(AvahiEntryGroup &group, AddService(group, i, name); } +void +Publisher::RegisterServices(AvahiEntryGroup &g) +{ + AddServices(g, services, name.c_str()); + + if (int error = avahi_entry_group_commit(&g); + error != AVAHI_OK) + throw MakeError(error, "Failed to commit Avahi service group"); +} + void Publisher::RegisterServices(AvahiClient *c) { @@ -140,11 +150,7 @@ Publisher::RegisterServices(AvahiClient *c) throw MakeError(*c, "Failed to create Avahi service group"); } - AddServices(*group, services, name.c_str()); - - if (int error = avahi_entry_group_commit(group.get()); - error != AVAHI_OK) - throw MakeError(error, "Failed to commit Avahi service group"); + RegisterServices(*group); } void diff --git a/src/lib/avahi/Publisher.hxx b/src/lib/avahi/Publisher.hxx index 807184c36..37876b4cd 100644 --- a/src/lib/avahi/Publisher.hxx +++ b/src/lib/avahi/Publisher.hxx @@ -68,6 +68,7 @@ private: AvahiEntryGroupState state, void *userdata) noexcept; + void RegisterServices(AvahiEntryGroup &g); void RegisterServices(AvahiClient *c); /* virtual methods from class AvahiConnectionListener */