Refactor HTTP::Server to support Universal Port:

These changes are necessary to support the Universal port feature. Synopsis:

* Persist HTTP peer io_service::work lifetime:
This simplification eliminates any potential for bugs caused by incorrect
lifetime management of the io_service::work object.

* Restructure Door to prevent data races, and handle clean exit:
The Server, Door, Door::detector, and Peer objects work together to
correctly implement graceful stop and destructors that block until
all child objects have been destroyed.

Cleanups:
* De-pimpl HTTP::Server
* Rename ServerImpl data members
* Tidy up HTTP::Port interface
This commit is contained in:
Vinnie Falco
2014-10-15 00:41:10 -07:00
parent 2fd139b307
commit dbdf68b248
15 changed files with 699 additions and 764 deletions

View File

@@ -37,7 +37,8 @@ ServerHandlerImp::ServerHandlerImp (Stoppable& parent, JobQueue& jobQueue,
, m_journal (deprecatedLogs().journal("Server"))
, m_jobQueue (jobQueue)
, m_networkOPs (networkOPs)
, m_server (*this, deprecatedLogs().journal("Server"))
, m_server (HTTP::make_Server(
*this, deprecatedLogs().journal("Server")))
, setup_ (setup)
{
if (setup_.secure)
@@ -49,7 +50,7 @@ ServerHandlerImp::ServerHandlerImp (Stoppable& parent, JobQueue& jobQueue,
ServerHandlerImp::~ServerHandlerImp()
{
m_server.stop();
m_server = nullptr;
}
void
@@ -77,9 +78,9 @@ ServerHandlerImp::setup (beast::Journal journal)
port.port = ep.port();
port.context = m_context.get ();
HTTP::Ports ports;
ports.push_back (port);
m_server.setPorts (ports);
std::vector<HTTP::Port> list;
list.push_back (port);
m_server->ports(list);
}
}
else
@@ -93,7 +94,7 @@ ServerHandlerImp::setup (beast::Journal journal)
void
ServerHandlerImp::onStop()
{
m_server.stopAsync();
m_server->close();
}
//--------------------------------------------------------------------------
@@ -256,7 +257,7 @@ ServerHandlerImp::processRequest (std::string const& request,
void
ServerHandlerImp::onWrite (beast::PropertyStream::Map& map)
{
m_server.onWrite (map);
m_server->onWrite (map);
}
//------------------------------------------------------------------------------

View File

@@ -38,7 +38,7 @@ private:
beast::Journal m_journal;
JobQueue& m_jobQueue;
NetworkOPs& m_networkOPs;
HTTP::Server m_server;
std::unique_ptr<HTTP::Server> m_server;
std::unique_ptr <RippleSSLContext> m_context;
RPC::Setup setup_;