1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:57:34 +00:00

Kernel: Fix race conditions processing async device requests

This commit is contained in:
Tom 2021-02-06 16:59:32 -07:00 committed by Andreas Kling
parent 8177f2474b
commit 5ccc3637e3
4 changed files with 23 additions and 41 deletions

View file

@ -72,14 +72,11 @@ public:
NonnullRefPtr<AsyncRequestType> make_request(Args&&... args)
{
auto request = adopt(*new AsyncRequestType(*this, forward<Args>(args)...));
bool was_empty;
{
ScopedSpinLock lock(m_requests_lock);
was_empty = m_requests.is_empty();
m_requests.append(request);
}
ScopedSpinLock lock(m_requests_lock);
bool was_empty = m_requests.is_empty();
m_requests.append(request);
if (was_empty)
request->do_start({});
request->do_start(move(lock));
return request;
}