mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-22 12:05:53 +00:00
Fix server to block until listening
This commit is contained in:
@@ -142,7 +142,6 @@ public:
|
|||||||
boost::system::error_code const ec = server.join ();
|
boost::system::error_code const ec = server.join ();
|
||||||
|
|
||||||
results.server = Result (ec, server.name ());
|
results.server = Result (ec, server.name ());
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
startThread ();
|
startThread ();
|
||||||
|
|
||||||
|
// For server roles block until the thread is litening.
|
||||||
|
//
|
||||||
|
if (get_role () == PeerRole::server)
|
||||||
|
m_listening.wait ();
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code join ()
|
error_code join ()
|
||||||
@@ -282,7 +287,8 @@ public:
|
|||||||
|
|
||||||
void do_listen ()
|
void do_listen ()
|
||||||
{
|
{
|
||||||
if (failure (get_native_acceptor ().open (get_endpoint (get_role ()).protocol (), error ())))
|
if (failure (get_native_acceptor ().open (
|
||||||
|
get_endpoint (get_role ()).protocol (), error ())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// VFALCO TODO Figure out how to not hard code boost::asio::socket_base
|
// VFALCO TODO Figure out how to not hard code boost::asio::socket_base
|
||||||
@@ -297,6 +303,8 @@ public:
|
|||||||
if (failure (get_native_acceptor ().listen (
|
if (failure (get_native_acceptor ().listen (
|
||||||
boost::asio::socket_base::max_connections, error ())))
|
boost::asio::socket_base::max_connections, error ())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_listening.signal ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_deadline (error_code const& ec)
|
void on_deadline (error_code const& ec)
|
||||||
@@ -326,6 +334,13 @@ public:
|
|||||||
|
|
||||||
void finished ()
|
void finished ()
|
||||||
{
|
{
|
||||||
|
// If the server errors out it will come through
|
||||||
|
// here so signal the listening event and unblock
|
||||||
|
// the main thread.
|
||||||
|
//
|
||||||
|
if (get_role () == PeerRole::server)
|
||||||
|
m_listening.signal ();
|
||||||
|
|
||||||
if (m_timer_set)
|
if (m_timer_set)
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
@@ -359,6 +374,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
WaitableEvent m_listening;
|
||||||
WaitableEvent m_join;
|
WaitableEvent m_join;
|
||||||
|
|
||||||
// for async peers
|
// for async peers
|
||||||
|
|||||||
Reference in New Issue
Block a user