diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-22 16:05:58 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-24 08:19:19 -0700 |
commit | 2c8343aa8233333dae0caf91f25bf1fe4689c88e (patch) | |
tree | c3b60896400a8b556f698553acccb5022cf02c4e /include | |
parent | 8b448786fed2251c345ff6ccbeb65afac8af8cf1 (diff) | |
download | qtlocation-mapboxgl-2c8343aa8233333dae0caf91f25bf1fe4689c88e.tar.gz |
[core] Block in Mailbox::close() until neither receive nor push are in progress
Otherwise, an ActorRef that's in the process of sending a message could attempt to access an invalid Scheduler reference:
Thread 1 Thread 2
--------------------------------------------------
Scheduler::Scheduler
Actor::Actor
weakMailbox.lock()
Actor::~Actor
Scheduler::~Scheduler
mailbox->push()
scheduler.schedule() 💣
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/actor/mailbox.hpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/mbgl/actor/mailbox.hpp b/include/mbgl/actor/mailbox.hpp index cff0de243a..1327e8e6fe 100644 --- a/include/mbgl/actor/mailbox.hpp +++ b/include/mbgl/actor/mailbox.hpp @@ -23,8 +23,10 @@ public: private: Scheduler& scheduler; - std::mutex closingMutex; - bool closing { false }; + std::mutex receivingMutex; + std::mutex pushingMutex; + + bool closed { false }; std::mutex queueMutex; std::queue<std::unique_ptr<Message>> queue; |