zaphoyd / websocketpp

C++ websocket client/server library
http://www.zaphoyd.com/websocketpp
Other
7.01k stars 1.97k forks source link

Thread safety for message pool operations #64

Open zaphoyd opened 12 years ago

megabyte1024 commented 12 years ago

About thread safety.... By reading the issue #62, I tried to implement a multithreading server using the ASIO's threads pool ability ( http://think-async.com/Asio/Recipes ). It crashes. The 1st step to get rid of it, I created a lock to access the endpoint's m_connections member by adding a recursive mutex

boost::recursive_mutex m_connections_locker;

and lock it in methods where there is access to the connections list using the following code

boost::recursive_mutex::scoped_lock lck(m_connections_locker);

in these methods

close_all create_connection remove_connection

zaphoyd commented 12 years ago

yep thats the plan.

megabyte1024 commented 12 years ago

good... I will post news ASAP if I discover something...