This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch improve_async_appender
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit dcd1156033c56fbfbda7756af7c454b65b9daa7a
Author: Stephen Webb <[email protected]>
AuthorDate: Sat Feb 17 15:32:45 2024 +1100

    Prevent infinite wait when buffer is full
---
 src/main/cpp/asyncappender.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp
index bf0d71e3..1c3390ae 100644
--- a/src/main/cpp/asyncappender.cpp
+++ b/src/main/cpp/asyncappender.cpp
@@ -552,17 +552,18 @@ void AsyncAppender::dispatch()
                LoggingEventList events;
 #if USE_ATOMIC_QUEUE
                auto eventList = priv->eventList.pop_all_reverse();
+               priv->approxListSize = 0;
                if (!eventList)
                {
                        std::unique_lock<std::mutex> lock(priv->bufferMutex);
                        priv->bufferNotEmpty.wait(lock, [this, &eventList]() -> 
bool
                                {
                                        eventList = 
priv->eventList.pop_all_reverse();
+                                       priv->approxListSize = 0;
                                        return eventList || priv->closed;
                                }
                        );
                }
-               priv->approxListSize = 0;
                priv->bufferNotFull.notify_all();
                while (eventList)
                {

Reply via email to