From bbea867145674c7e20482c9346153d1f304138b9 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Fri, 31 Jul 2020 16:07:07 +0300 Subject: [PATCH] TsList: make lock non-static again GitOrigin-RevId: 7df7dee8bf609f928b351b448c9e132fb2118942 --- td/telegram/Td.cpp | 2 -- tdutils/td/utils/TsList.h | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index f61c42b44..373479fc0 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3737,8 +3737,6 @@ void Td::start_up() { LOG_IF(FATAL, symbol != c) << "TDLib requires little-endian platform"; } - TsList::lock().unlock(); // initialize mutex before any NetQuery - VLOG(td_init) << "Create Global"; set_context(std::make_shared()); G()->set_net_query_stats(td_options_.net_query_stats); diff --git a/tdutils/td/utils/TsList.h b/tdutils/td/utils/TsList.h index 0d650e609..c9adaf758 100644 --- a/tdutils/td/utils/TsList.h +++ b/tdutils/td/utils/TsList.h @@ -180,9 +180,8 @@ class TsList : public TsListNode { } this->parent = nullptr; } - static std::unique_lock lock() TD_WARN_UNUSED_RESULT { - static std::mutex mutex; - return std::unique_lock(mutex); + std::unique_lock lock() TD_WARN_UNUSED_RESULT { + return std::unique_lock(mutex_); } TsListNode *begin() { return this->get_next(); @@ -198,6 +197,9 @@ class TsList : public TsListNode { } return res; } + + private: + std::mutex mutex_; }; template