From d6ed05eb74bf351ad0662078c0e548ea3e5c01ba Mon Sep 17 00:00:00 2001 From: vpaleologue Date: Thu, 28 Jul 2016 14:06:01 +0200 Subject: [PATCH] Fix Helgrind warning on using pthread_cond_signal while unlocked Helgrind would report a dubious use of pthread_cond_signal before this patch. The original code was already correct, though, but this one seems to be preferred. --- include/boost/asio/detail/posix_event.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/asio/detail/posix_event.hpp b/include/boost/asio/detail/posix_event.hpp index 3b905ba5..69813c8d 100644 --- a/include/boost/asio/detail/posix_event.hpp +++ b/include/boost/asio/detail/posix_event.hpp @@ -66,9 +66,9 @@ class posix_event BOOST_ASIO_ASSERT(lock.locked()); state_ |= 1; bool have_waiters = (state_ > 1); - lock.unlock(); if (have_waiters) ::pthread_cond_signal(&cond_); // Ignore EINVAL. + lock.unlock(); } // If there's a waiter, unlock the mutex and signal it. @@ -79,8 +79,8 @@ class posix_event state_ |= 1; if (state_ > 1) { - lock.unlock(); ::pthread_cond_signal(&cond_); // Ignore EINVAL. + lock.unlock(); return true; } return false;