fix(sni): prevent use-after-free and infinite retry in Host proxy retry

Store the retry timeout connection in a Host member and disconnect it in
~Host, so a Host destroyed within the retry window no longer invokes the
timeout callback on freed memory. Cap the retries (MAX_RETRIES) so a
watcher that never reappears no longer spins forever every 200ms; reset
the counter on success and when the watcher name vanishes.
This commit is contained in:
Alex
2026-07-03 21:39:36 +02:00
parent 05dbcb24a0
commit 5181f84648
2 changed files with 17 additions and 2 deletions
+2
View File
@@ -43,6 +43,8 @@ class Host {
std::size_t watcher_id_;
GCancellable* cancellable_ = nullptr;
SnWatcher* watcher_ = nullptr;
sigc::connection retry_connection_;
unsigned retry_count_ = 0;
const Json::Value& config_;
const Bar& bar_;
const std::function<void(std::unique_ptr<Item>&)> on_add_;