From ff8d502a8599468fa7e761842f0352bdc453e69a Mon Sep 17 00:00:00 2001 From: Walt Karas Date: Mon, 29 Mar 2021 07:45:41 -0500 Subject: [PATCH] Add thread yeield to avoid busy waiting in LogObject::_checkout_write(). (#7576) (cherry picked from commit f278427b1ecdc5ce9e758de51a7faf83bcc58643) --- proxy/logging/LogObject.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc index 0351005e13a..10dfcc1bbeb 100644 --- a/proxy/logging/LogObject.cc +++ b/proxy/logging/LogObject.cc @@ -39,6 +39,7 @@ #include #include +#include static bool should_roll_on_time(Log::RollingEnabledValues roll) @@ -462,7 +463,9 @@ LogObject::_checkout_write(size_t *write_offset, size_t bytes_needed) break; case LogBuffer::LB_RETRY: - // no more room, but another thread should be taking care of creating a new buffer, so try again + // no more room, but another thread should be taking care of creating a new buffer, so yield to let + // the other thread finish, then try again + std::this_thread::yield(); break; case LogBuffer::LB_BUFFER_TOO_SMALL: