LibWeb: Skip SHTQ processing if ongoing task form queue is not finished

Fixes a bug when session history traversal queue task could be
interrupted by another SHTQ task execution. For example:
1. SHTQ timer callback starts executing a task from the queue.
2. spin_until() is invoked during task execution.
3. SHTQ timer callback starts executing a task from the queue.
This commit is contained in:
Aliaksandr Kalenik 2024-04-05 16:00:14 +02:00 committed by Alexander Kalenik
commit 4ca715d2ef
Notes: sideshowbarker 2024-07-17 06:51:10 +09:00

View file

@ -25,9 +25,15 @@ public:
SessionHistoryTraversalQueue()
{
m_timer = Core::Timer::create_single_shot(0, [this] {
if (m_is_task_running && m_queue.size() > 0) {
m_timer->start();
return;
}
while (m_queue.size() > 0) {
m_is_task_running = true;
auto entry = m_queue.take_first();
entry.steps();
m_is_task_running = false;
}
}).release_value_but_fixme_should_propagate_errors();
}
@ -60,6 +66,7 @@ public:
private:
Vector<SessionHistoryTraversalQueueEntry> m_queue;
RefPtr<Core::Timer> m_timer;
bool m_is_task_running { false };
};
}