From 061c4f65d559ae217b7eb444c2b9bf3e62bfd0e6 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 20 Jul 2022 10:56:48 +0300 Subject: [PATCH] Drop context for SemaphoreActor before creation of the actor. --- td/telegram/net/Session.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 9693bfb19..c04ce0f22 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -69,11 +69,6 @@ class SemaphoreActor final : public Actor { size_t capacity_; VectorQueue>> pending_; - void start_up() final { - set_context(std::make_shared()); - set_tag(string()); - } - void finish(Result) { capacity_++; if (!pending_.empty()) { @@ -137,7 +132,11 @@ class GenAuthKeyActor final : public Actor { static TD_THREAD_LOCAL Semaphore *semaphore_; Semaphore &get_handshake_semaphore() { + auto old_context = set_context(std::make_shared()); + auto old_tag = set_tag(string()); init_thread_local(semaphore_, 50); + set_context(std::move(old_context)); + set_tag(std::move(old_tag)); return *semaphore_; }