mirror of https://github.com/Icinga/icinga2.git
RedisConnection#Connect(): wait for all promises to be completed
by the read loop from the previous connection.
This commit is contained in:
parent
9585a63fa0
commit
cac22fe38b
|
@ -262,6 +262,12 @@ void RedisConnection::Connect(asio::yield_context& yc)
|
|||
|
||||
boost::asio::deadline_timer timer (m_Strand.context());
|
||||
|
||||
auto waitForReadLoop ([this, &yc]() {
|
||||
while (!m_Queues.FutureResponseActions.empty()) {
|
||||
IoEngine::YieldCurrentCoroutine(yc);
|
||||
}
|
||||
});
|
||||
|
||||
for (;;) {
|
||||
try {
|
||||
if (m_Path.IsEmpty()) {
|
||||
|
@ -294,6 +300,7 @@ void RedisConnection::Connect(asio::yield_context& yc)
|
|||
}
|
||||
|
||||
Handshake(conn, yc);
|
||||
waitForReadLoop();
|
||||
m_TlsConn = std::move(conn);
|
||||
} else {
|
||||
Log(m_Parent ? LogNotice : LogInformation, "IcingaDB")
|
||||
|
@ -305,6 +312,7 @@ void RedisConnection::Connect(asio::yield_context& yc)
|
|||
|
||||
icinga::Connect(conn->next_layer(), m_Host, Convert::ToString(m_Port), yc);
|
||||
Handshake(conn, yc);
|
||||
waitForReadLoop();
|
||||
m_TcpConn = std::move(conn);
|
||||
}
|
||||
} else {
|
||||
|
@ -317,6 +325,7 @@ void RedisConnection::Connect(asio::yield_context& yc)
|
|||
|
||||
conn->next_layer().async_connect(Unix::endpoint(m_Path.CStr()), yc);
|
||||
Handshake(conn, yc);
|
||||
waitForReadLoop();
|
||||
m_UnixConn = std::move(conn);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue