kit/Kit.cpp | 49 +++++++++++++++++++++---------------------------- net/Socket.hpp | 1 + 2 files changed, 22 insertions(+), 28 deletions(-)
New commits: commit 07bf5984305955725c1cfe0d5cada0b46d42dbc6 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Tue Jul 14 17:06:11 2020 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Tue Jul 14 16:56:20 2020 +0200 Make objects and threads go away more reliably in the iOS app We probably used to have circular references that made KitSocketPoll and KitWebSocketHandler objects hang around forever, or something. (Not a problem in web-based Online where kit processes have a restricted lifetime.) Change-Id: Ia6eebc51f4a4a8fb4f69a2c83a0131de921ea1d6 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98744 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> diff --git a/kit/Kit.cpp b/kit/Kit.cpp index f10493e50..284e552f3 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -1623,19 +1623,7 @@ class KitSocketPoll final : public SocketPoll public: ~KitSocketPoll() { -#ifdef IOS - std::unique_lock<std::mutex> lock(KSPollsMutex); - std::shared_ptr<KitSocketPoll> p; - auto i = KSPolls.begin(); - for (; i != KSPolls.end(); ++i) - { - p = i->lock(); - if (p && p.get() == this) - break; - } - assert(i != KSPolls.end()); - KSPolls.erase(i); -#endif + // Just to make it easier to set a breakpoint } static std::shared_ptr<KitSocketPoll> create() @@ -1645,7 +1633,6 @@ public: #ifdef IOS std::unique_lock<std::mutex> lock(KSPollsMutex); KSPolls.push_back(result); - // KSPollsCV.notify_one(); #endif return result; } @@ -1762,6 +1749,11 @@ public: { } + ~KitWebSocketHandler() + { + // Just to make it easier to set a breakpoint + } + protected: void handleMessage(const std::vector<char>& data) override { @@ -1881,10 +1873,13 @@ protected: SigUtil::setTerminationFlag(); #endif #ifdef IOS - std::unique_lock<std::mutex> lock(_ksPoll->terminationMutex); - _ksPoll->terminationFlag = true; - _ksPoll->terminationCV.notify_all(); + { + std::unique_lock<std::mutex> lock(_ksPoll->terminationMutex); + _ksPoll->terminationFlag = true; + _ksPoll->terminationCV.notify_all(); + } #endif + _ksPoll.reset(); } }; @@ -1903,22 +1898,20 @@ int pollCallback(void* pData, int timeoutUs) return reinterpret_cast<KitSocketPoll*>(pData)->kitPoll(timeoutUs); #else std::unique_lock<std::mutex> lock(KitSocketPoll::KSPollsMutex); - if (KitSocketPoll::KSPolls.size() == 0) + std::vector<std::shared_ptr<KitSocketPoll>> v; + for (const auto &i : KitSocketPoll::KSPolls) + { + auto p = i.lock(); + if (p) + v.push_back(p); + } + lock.unlock(); + if (v.size() == 0) { - // KitSocketPoll::KSPollsCV.wait(lock); - lock.unlock(); std::this_thread::sleep_for(std::chrono::microseconds(timeoutUs)); } else { - std::vector<std::shared_ptr<KitSocketPoll>> v; - for (const auto &i : KitSocketPoll::KSPolls) - { - auto p = i.lock(); - if (p) - v.push_back(p); - } - lock.unlock(); for (const auto &p : v) p->kitPoll(timeoutUs); } diff --git a/net/Socket.hpp b/net/Socket.hpp index 9ee336950..84b4bfafd 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -799,6 +799,7 @@ public: { assertCorrectThread(); _socketHandler->onDisconnect(); + _socketHandler.reset(); } if (!_shutdownSignalled) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits