Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/platform/linux/publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ namespace platf::publish {
if (poll_thread.joinable()) {
poll_thread.join();
}

poll.reset();
}
};

Expand Down Expand Up @@ -581,6 +583,16 @@ namespace platf::publish {
return nullptr;
}

return std::make_unique<deinit_t>(std::jthread {avahi::simple_poll_loop, poll.get()});
return std::make_unique<deinit_t>(std::jthread {[]() {
avahi::simple_poll_loop(poll.get());

// simple_poll_loop() returns only once publishing has stopped for good: either at
// shutdown, or because a failure path called simple_poll_quit(). Nothing services the
// client's D-Bus connection past this point, so release it here rather than leave it
// open and subscribed until the process exits. The entry group is owned by the client,
// so clear it too, otherwise a later start() would reuse a dangling pointer.
client.reset();
group = nullptr;
Comment on lines +594 to +595

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add regression coverage for Avahi cleanup

This new exit-path cleanup is the behavior the fix depends on, but the commit only changes src/platform/linux/publish.cpp and adds no test that exercises a failure path where simple_poll_quit() makes the poll loop return and then verifies the client is released and the entry group is cleared. Please add focused coverage, e.g. with stubbed Avahi function pointers, so this resource-leak fix cannot silently regress.

Useful? React with 👍 / 👎.

}});
}
} // namespace platf::publish
Loading