mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 13:14:32 +02:00
RedisConnection#Connect(): get rid of spin lock
Instead of IoEngine::YieldCurrentCoroutine(yc) until m_Queues.FutureResponseActions.empty(), async-wait a CV which is updated along with m_Queues.FutureResponseActions.
This commit is contained in:
parent
060d8b185e
commit
2739f7f189
@ -302,12 +302,6 @@ 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()) {
|
||||
@ -339,7 +333,7 @@ void RedisConnection::Connect(asio::yield_context& yc)
|
||||
}
|
||||
|
||||
Handshake(conn, yc);
|
||||
waitForReadLoop();
|
||||
m_QueuedReads.WaitForClear(yc);
|
||||
m_TlsConn = std::move(conn);
|
||||
} else {
|
||||
Log(m_Parent ? LogNotice : LogInformation, "IcingaDB")
|
||||
@ -350,7 +344,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_QueuedReads.WaitForClear(yc);
|
||||
m_TcpConn = std::move(conn);
|
||||
}
|
||||
} else {
|
||||
@ -362,7 +356,7 @@ void RedisConnection::Connect(asio::yield_context& yc)
|
||||
|
||||
conn->next_layer().async_connect(Unix::endpoint(m_Path.CStr()), yc);
|
||||
Handshake(conn, yc);
|
||||
waitForReadLoop();
|
||||
m_QueuedReads.WaitForClear(yc);
|
||||
m_UnixConn = std::move(conn);
|
||||
}
|
||||
|
||||
@ -394,7 +388,7 @@ void RedisConnection::Connect(asio::yield_context& yc)
|
||||
void RedisConnection::ReadLoop(asio::yield_context& yc)
|
||||
{
|
||||
for (;;) {
|
||||
m_QueuedReads.Wait(yc);
|
||||
m_QueuedReads.WaitForSet(yc);
|
||||
|
||||
while (!m_Queues.FutureResponseActions.empty()) {
|
||||
auto item (std::move(m_Queues.FutureResponseActions.front()));
|
||||
|
@ -262,7 +262,8 @@ namespace icinga
|
||||
std::set<QueryPriority> m_SuppressedQueryKinds;
|
||||
|
||||
// Indicate that there's something to send/receive
|
||||
AsioEvent m_QueuedWrites, m_QueuedReads;
|
||||
AsioEvent m_QueuedWrites;
|
||||
AsioDualEvent m_QueuedReads;
|
||||
|
||||
std::function<void(boost::asio::yield_context& yc)> m_ConnectedCallback;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user