mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-26 09:35:04 +02:00
The `ThreadPoolLooper` should increment `m_busy_count` before attempting to access the global queue. Otherwise, there exists a possible race condition where `wait_for_all` checks the exit conditions before the looper increments `m_busy_count` but after it empties the `ThreadPool` queue. Next, incrementing / decrementing `m_busy_count` is moved to be the responsibility of `ThreadPoolLooper`. Otherwise, it is possible that decrementing `m_busy_count` in the caller of `Looper::next` causes `m_busy_count` to underflow if the call to `Looper::next` returns before incrementing `m_busy_count`. (cherry picked from commit 8d336d2a25b168d246bceb88178571ba066e3357)