diff --git a/src/async_connection.cpp b/src/async_connection.cpp index 490dfc1..2451e1a 100644 --- a/src/async_connection.cpp +++ b/src/async_connection.cpp @@ -204,9 +204,10 @@ namespace redis { } void AsyncConnection::wakeup_event_thread() { - std::lock_guard lock(m_local_data->libev_mutex); - if (ev_async_pending(&m_local_data->watcher_wakeup) == false) + if (ev_async_pending(&m_local_data->watcher_wakeup) == false) { + std::lock_guard lock(m_local_data->libev_mutex); ev_async_send(m_libev_loop_thread.get(), &m_local_data->watcher_wakeup); + } } std::mutex& AsyncConnection::event_mutex() {