Skip to content

Commit e575917

Browse files
authored
fix(linux/publish): release the Avahi client when the poll loop stops (#5545)
1 parent 233bb50 commit e575917

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/platform/linux/publish.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ namespace platf::publish {
551551
if (poll_thread.joinable()) {
552552
poll_thread.join();
553553
}
554+
555+
poll.reset();
554556
}
555557
};
556558

@@ -581,6 +583,16 @@ namespace platf::publish {
581583
return nullptr;
582584
}
583585

584-
return std::make_unique<deinit_t>(std::jthread {avahi::simple_poll_loop, poll.get()});
586+
return std::make_unique<deinit_t>(std::jthread {[]() {
587+
avahi::simple_poll_loop(poll.get());
588+
589+
// simple_poll_loop() returns only once publishing has stopped for good: either at
590+
// shutdown, or because a failure path called simple_poll_quit(). Nothing services the
591+
// client's D-Bus connection past this point, so release it here rather than leave it
592+
// open and subscribed until the process exits. The entry group is owned by the client,
593+
// so clear it too, otherwise a later start() would reuse a dangling pointer.
594+
client.reset();
595+
group = nullptr;
596+
}});
585597
}
586598
} // namespace platf::publish

0 commit comments

Comments
 (0)