Server deadlock fixes

This commit is contained in:
Vinnie Falco
2016-02-09 15:14:51 -05:00
parent be71e8afa2
commit ba38bfad9d
3 changed files with 57 additions and 51 deletions

View File

@@ -26,7 +26,6 @@
#include <beast/intrusive/List.h>
#include <beast/threads/Thread.h>
#include <boost/asio.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/optional.hpp>
#include <array>
#include <chrono>
@@ -55,17 +54,13 @@ struct Stat
class ServerImpl : public Server
{
public:
class Child : public boost::intrusive::list_base_hook <
boost::intrusive::link_mode <boost::intrusive::normal_link>>
struct Child
{
public:
virtual ~Child() = default;
virtual void close() = 0;
};
private:
using list_type = boost::intrusive::make_list <Child,
boost::intrusive::constant_time_size <false>>::type;
using clock_type = std::chrono::system_clock;
enum
@@ -75,7 +70,7 @@ private:
using Doors = std::vector <std::shared_ptr<Door>>;
Handler& handler_;
Handler* handler_;
beast::Journal journal_;
boost::asio::io_service& io_service_;
boost::asio::io_service::strand strand_;
@@ -83,7 +78,8 @@ private:
std::mutex mutable mutex_;
std::condition_variable cond_;
list_type list_;
std::vector<std::shared_ptr<Door>> list_;
std::size_t accepting_ = 0;
std::deque <Stat> stats_;
int high_ = 0;
@@ -114,7 +110,7 @@ public:
Handler&
handler()
{
return handler_;
return *handler_;
}
boost::asio::io_service&
@@ -124,10 +120,7 @@ public:
}
void
add (Child& child);
void
remove (Child& child);
remove();
bool
closed();